TypeError: Failed to execute 'fetch' on 'Window': Invalid value
This also happened to me when I tried to add an Authorization
header to my fetch calls. In my case it was caused by a newline character in the header string, i.e. Bearer:\nsomelong-token
. Changing the new line to a space solved the problem.
For me, i had an invalid character in a key of the header object. I accidentally included the ":" and this throws the error described. Really difficult to visually see in the chrome console. Hope it helps someone.
{ 'Authorization:':'Bearer etc...' }
I had this when passing a string with a newline character into the header object for example:
const myString = 'this is a string \nand this is a new line';headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}`, 'subscriptionId': myString}