I am currently developing an office add-in specifically tailored for use in Word. Additionally, I have created an API utilizing Django that handles incoming data as 'formData'. Within my office add-in, I have implemented a function containing a custom fetch request:
const response = await fetch('http://127.0.0.1:8000/api/v1/my-upload-api', {
method: 'POST',
body: formData
});
Upon running the code, the API is successfully invoked, and my backend executes properly to upload the file. However, within the add-in code, I encounter a TypeError: Failed to fetch
. Despite attempting to debug with log statements after the fetch request, the TypeError persists (lineNumber: 30) leading directly into the catch block. I also tried managing the response using promises in this manner:
const response = await fetch('http://127.0.0.1:8000/api/v1/upload-contracts', {
method: 'POST',
body: formData
}).then((response) =>{
response.json().then(result => {
console.log(result);
return result;
});
});
Unfortunately, this approach did not resolve the issue. Any assistance would be greatly appreciated. Thank you!