I\'ve tried to use fetch to call from backend using react, without libs (such as Axios). So I created this function:
export function api(url, method, body, i
This error happened to me as well, however with different circumstances. I would like to share it in case someone else has this issue.
So I got the error "TypeError: Failed to execute 'fetch' on 'Window': Invalid value" when I tried to upload a file with HTTP POST without using FormData. To solve the issue I used FormData object and appended properties and file itself:
let formData = new FormData();
formData.append('name', fileName);
formData.append('data', file);
then I used fetch to send the file with POST method. Here is pseudo code:
const options = {method: 'POST', formData};
fetch('http://www.someURL.com/upload', options);