File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -8,16 +8,22 @@ interface renderError extends ToastContentProps {
8
8
9
9
export function uploadFormDataToIPFS ( formData : FormData ) {
10
10
return toast . promise (
11
- fetch ( "/.netlify/functions/uploadToIPFS" , {
12
- method : "POST" ,
13
- body : formData ,
14
- } ) ,
11
+ new Promise ( ( resolve , reject ) =>
12
+ fetch ( "/.netlify/functions/uploadToIPFS" , {
13
+ method : "POST" ,
14
+ body : formData ,
15
+ } ) . then ( async ( response ) =>
16
+ response . status === 200
17
+ ? resolve ( response )
18
+ : reject ( { message : ( await response . json ( ) ) . error . reason } )
19
+ )
20
+ ) ,
15
21
{
16
22
pending : "Uploading evidence to IPFS..." ,
17
- success : "Uploaded to IPFS !" ,
23
+ success : "Uploaded successfully !" ,
18
24
error : {
19
25
render ( { data } : renderError ) {
20
- return `Upload failed ${ data . message } ` ;
26
+ return `Upload failed: ${ data . message } ` ;
21
27
} ,
22
28
} ,
23
29
} ,
You can’t perform that action at this time.
0 commit comments