Skip to content

Commit

Permalink
Merge pull request #27 from PinataCloud/chore/refactor-upload-response
Browse files Browse the repository at this point in the history
chore: Refactor upload response based on new API response
  • Loading branch information
stevedylandev authored Sep 5, 2024
2 parents 3c85d97 + 6dc4b0f commit 704dd4f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/core/uploads/base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ export const uploadBase64 = async (
);
}

const res: UploadResponse = await request.json();
return res;
const res = await request.json();
const resData: UploadResponse = res.data;
return resData;
} catch (error) {
if (error instanceof PinataError) {
throw error;
Expand Down
5 changes: 3 additions & 2 deletions src/core/uploads/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ export const uploadFile = async (
errorData,
);
}
const res: UploadResponse = await request.json();
return res;
const res = await request.json();
const resData: UploadResponse = res.data;
return resData;
} catch (error) {
if (error instanceof PinataError) {
throw error;
Expand Down
5 changes: 3 additions & 2 deletions src/core/uploads/fileArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ export const uploadFileArray = async (
);
}

const res: UploadResponse = await request.json();
return res;
const res = await request.json();
const resData: UploadResponse = res.data;
return resData;
} catch (error) {
if (error instanceof PinataError) {
throw error;
Expand Down
5 changes: 3 additions & 2 deletions src/core/uploads/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ export const uploadJson = async <T extends JsonBody>(
);
}

const res: UploadResponse = await request.json();
return res;
const res = await request.json();
const resData: UploadResponse = res.data;
return resData;
} catch (error) {
if (error instanceof PinataError) {
throw error;
Expand Down
5 changes: 3 additions & 2 deletions src/core/uploads/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ export const uploadUrl = async (
);
}

const res: UploadResponse = await request.json();
return res;
const res = await request.json();
const resData: UploadResponse = res.data;
return resData;
} catch (error) {
if (error instanceof PinataError) {
throw error;
Expand Down

0 comments on commit 704dd4f

Please sign in to comment.