Skip to content

Commit

Permalink
internal server error
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroRosalba committed Oct 7, 2024
1 parent a877f9b commit 4c14cbd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions packages/nextjs/app/api/forms-ipfs/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ export async function POST(request: NextRequest){
// const data4 = JSON.parse(await request.json());
// console.log(data4);

const data = request.json();
console.log(data);
console.log("--------------");
const data = await request.formData();

// const title = data.get('title') as unknown as string;
// const description = data.get('description') as unknown as string;
// const authors = data.getAll('authors');
// const ipType = data.get('ipType');
const uploadFile = data.get('uploadFile') as unknown as File;

// const data2 = request.body;
// console.log(data2);
Expand All @@ -44,8 +48,16 @@ export async function POST(request: NextRequest){
// const uploadMockedData = await pinataClient.upload.json(mockedData);
// const mockedUrl = await pinataClient.gateways.convert(uploadMockedData.IpfsHash);
// console.log(mockedUrl);

const uploadData = await pinataClient.upload.json(data);

const userObject = {
// title: title,
// description: description,
// authors: authors,
// ipType: ipType,
uploadFile: uploadFile
};

const uploadData = await pinataClient.upload.file(uploadFile);
const url = await pinataClient.gateways.convert(uploadData.IpfsHash);

console.log(url);
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/app/uploadIP/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const uploadIP = () => {
try {
const response = await fetch('/api/forms-ipfs', {
method: 'POST',
body: submitString,
body: submitData,
});

if (!response.ok) {
Expand Down

0 comments on commit 4c14cbd

Please sign in to comment.