Hi @giri-zano
Would you be able to look at this code? I can’t figure out how to get the response from the fetch to be something that I can save() into the collection (or update())
I get a successful get with code 200 though.
I have made a backend code to work with and am using a specific item in my collection to play with.
Here’s a test URL https://www.c3f.org/userfiles/filemanager/1010/
export function getPDFfromAWS(fetchUrl) {
fetch(fetchUrl, {
"headers": {
"Content-Type": "application/pdf"
},
"method": "get",
"mode": 'no-cors',
})
.then( (httpResponse) => {
let url = httpResponse.url;
let statusCode = httpResponse.status;
let statusText = httpResponse.statusText;
let headers = httpResponse.headers;
let bodyUsed = httpResponse.bodyUsed;
var body = httpResponse.body;
if (httpResponse.ok) {
console.log(statusCode + " " + statusText);
let toUpdate = {
"_id": "f5ea6533-ad44-40a1-a1f6-1f5cc5d94ac5",
"applicationPdf": body,
};
wixData.update("GrantApplications", toUpdate)
.then( (results) => {
let item = results; //see item below
console.log(item)
} )
.catch( (err) => {
let errorMsg = err;
console.log(err)
} );
return httpResponse;
}
else {
return Promise.reject("Fetch did not succeed");
}
} )
.catch( (err) => {
console.log("error "+err);
} );
}