I am trying to send a new push subscription to my server but am encountering an error \"Uncaught (in promise) SyntaxError: Unexpected end of JSON input\" and the console say
For someone looking here later. I received this error not because of my headers but because I was not recursively appending the response body to a string to JSON.parse later.
As per the MDN example (I've taken out some parts of their example not immediately relevant):
reader.read().then(function processText({ done, value }) {
if (done) {
console.log("Stream complete");
return;
}
result += chunk;
return reader.read().then(processText);
});
For my issue I had to
Just in case this is helpful for you in the future and your issue is not header related, but related to the done value not being true with the initial JSON stream response.