SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data using fetch

后端 未结 1 1562
一个人的身影
一个人的身影 2020-12-07 06:16

I\'m using this function

obtenerCursos:async function(){
                    const data = await fetch(\'cursos.json\', {mode: \'no-cors\'});
                         


        
相关标签:
1条回答
  • 2020-12-07 06:49
    type: "opaque"
    

    This means that JavaScript cannot see the content of the response.

    Since JS can't see the content, the content it can see has zero length. So it gets to the end of the content before finding anything that would make it valid JSON.

    It is opaque because you said:

    mode: 'no-cors'
    

    Don't do that.

    0 讨论(0)
提交回复
热议问题