Uncaught (in promise) SyntaxError: Unexpected end of JSON input

前端 未结 4 1350
独厮守ぢ
独厮守ぢ 2020-12-18 01:47

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

4条回答
  •  轮回少年
    2020-12-18 02:14

    This might be a problem with the endpoint not passing the appropriate parameters in the response's header.

    In Chrome's console, inside the Network tab, check the headers sent by the endpoint and it should contain this: Example of proper response to allow requests from localhost and cross domains requests

    Ask the API developer to include this in the headers:

    "Access-Control-Allow-Origin" : "*", 
    "Access-Control-Allow-Credentials" : true 
    

提交回复
热议问题