Skip to content

Commit

Permalink
feat: Remove warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed May 31, 2024
1 parent d1b742a commit f03712e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-tips-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bnb-chain/greenfield-js-sdk': patch
---

feat: Remove warning in browser.
31 changes: 14 additions & 17 deletions packages/js-sdk/src/clients/spclient/spClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export class SpClient implements ISpClient {
},
) {
const R = superagent.put(url);
R.buffer(true);
R.timeout(timeout);
R.ok((res) => res.status < 500);

Expand All @@ -179,25 +178,23 @@ export class SpClient implements ISpClient {
});
}

try {
if (options.headers) {
(options.headers as Headers).forEach((v: string, k: string) => {
R.set(k, v);
});
}
if (callback && callback.onProgress) {
R.on('progress', (e) => {
callback.onProgress?.(e);
});
}

if (callback && callback.onProgress) {
R.on('progress', (e) => {
callback.onProgress?.(e);
});
}
const file = assertFileType(uploadFile) ? uploadFile.content : uploadFile;

const file = assertFileType(uploadFile) ? uploadFile.content : uploadFile;
// https://ladjs.github.io/superagent/docs/index.html#serializing-request-body
const sendFile =
isNode && R.get('Content-Type') === 'application/json' ? file.toString() : file;
if (isNode) {
R.buffer(true);
}

// https://ladjs.github.io/superagent/docs/index.html#serializing-request-body
const serializeFile =
isNode && R.get('Content-Type') === 'application/json' ? file.toString() : file;
const response = await R.send(serializeFile);
try {
const response = await R.send(sendFile);
const { status } = response;

if (status === SP_NOT_AVAILABLE_ERROR_CODE) {
Expand Down

0 comments on commit f03712e

Please sign in to comment.