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