refactor: switch from Fetch API to Axios (#1520)
* refactor: switch from Fetch API to Axios * fix: remove unwanted changes * fix: rewrite error handling for Axios and remove IPv4 first setting * style: run prettier * style: run prettier * fix: add back custom proxy agent * fix: add back custom proxy agent * fix: correct rebase issue * fix: resolve review comments
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import CollectionDetails from '@app/components/CollectionDetails';
|
||||
import type { Collection } from '@server/models/Collection';
|
||||
import axios from 'axios';
|
||||
import type { GetServerSideProps, NextPage } from 'next';
|
||||
|
||||
interface CollectionPageProps {
|
||||
@@ -13,7 +14,7 @@ const CollectionPage: NextPage<CollectionPageProps> = ({ collection }) => {
|
||||
export const getServerSideProps: GetServerSideProps<
|
||||
CollectionPageProps
|
||||
> = async (ctx) => {
|
||||
const res = await fetch(
|
||||
const response = await axios.get<Collection>(
|
||||
`http://${process.env.HOST || 'localhost'}:${
|
||||
process.env.PORT || 5055
|
||||
}/api/v1/collection/${ctx.query.collectionId}`,
|
||||
@@ -23,12 +24,10 @@ export const getServerSideProps: GetServerSideProps<
|
||||
: undefined,
|
||||
}
|
||||
);
|
||||
if (!res.ok) throw new Error();
|
||||
const collection: Collection = await res.json();
|
||||
|
||||
return {
|
||||
props: {
|
||||
collection,
|
||||
collection: response.data,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user