Fix codex sdk api syntax
This commit is contained in:
parent
1a3d145b63
commit
174a25e85c
|
@ -138,17 +138,15 @@ export function UploadFile({
|
|||
const { mutateAsync } = useMutation({
|
||||
mutationKey: ["upload"],
|
||||
mutationFn: (file: File) => {
|
||||
return codexData
|
||||
.upload(file, onProgress)
|
||||
.then((res) => {
|
||||
abort.current = res.abort;
|
||||
return res.result;
|
||||
})
|
||||
.then((safe) =>
|
||||
safe.error
|
||||
? Promise.reject(safe.data.message)
|
||||
: Promise.resolve(safe.data)
|
||||
);
|
||||
const res = codexData.upload(file, onProgress);
|
||||
|
||||
abort.current = res.abort;
|
||||
|
||||
return res.result.then((safe) =>
|
||||
safe.error
|
||||
? Promise.reject(safe.data.message)
|
||||
: Promise.resolve(safe.data)
|
||||
);
|
||||
},
|
||||
onError: (error) => {
|
||||
// worker.current?.terminate();
|
||||
|
|
|
@ -22,17 +22,14 @@ self.addEventListener("message", function (e) {
|
|||
});
|
||||
};
|
||||
|
||||
return codex.data
|
||||
.upload(rest.file, onProgress)
|
||||
.then((result) => {
|
||||
abort = result.abort;
|
||||
const res = codex.data.upload(rest.file, onProgress);
|
||||
|
||||
return result.result;
|
||||
})
|
||||
.then((value) => {
|
||||
self.postMessage({
|
||||
type: "completed",
|
||||
value,
|
||||
});
|
||||
abort = res.abort;
|
||||
|
||||
return res.result.then((value) => {
|
||||
self.postMessage({
|
||||
type: "completed",
|
||||
value,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue