Skip to content

Commit

Permalink
feat: add error codes on ipfs api routes
Browse files Browse the repository at this point in the history
  • Loading branch information
metalboyrick committed Oct 17, 2024
1 parent 65af29f commit ee9e4d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/nextjs/app/api/ipfs/add/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export async function POST(request: Request) {
try {
const body = await request.json();
const res = await ipfsClient.add(JSON.stringify(body));
return Response.json(res);
return Response.json(res, { status: 200 });
} catch (error) {
console.log("Error adding to ipfs", error);
return Response.json({ error: "Error adding to ipfs" });
return Response.json({ error: "Error adding to ipfs" }, { status: 500 });
}
}
7 changes: 5 additions & 2 deletions packages/nextjs/app/api/ipfs/get-metadata/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ export async function POST(request: Request) {
try {
const { ipfsHash } = await request.json();
const res = await getNFTMetadataFromIPFS(ipfsHash);
return Response.json(res);
return Response.json(res, { status: 200 });
} catch (error) {
console.log("Error getting metadata from ipfs", error);
return Response.json({ error: "Error getting metadata from ipfs" });
return Response.json(
{ error: "Error getting metadata from ipfs" },
{ status: 500 },
);
}
}

0 comments on commit ee9e4d2

Please sign in to comment.