JSON Parse error: Unrecognized token'<' - react-native

前端 未结 10 1604
执笔经年
执笔经年 2020-12-09 11:21

\"JSON Parse error: Unrecognized token\'<\'\" Error is showing while hitting the api. Code is attached below Note* : Response is in the JSON format.

10条回答
  •  不思量自难忘°
    2020-12-09 12:06

    I fixed this problem my changing the multiline URLs in template literals to single-line URLs.

    I had this problem on iOS, but not Android. The "same" code according to version control, and state according to testing procedures, led to this error on the iOS device emulator but not the Android device emulator.

    Apple and Windows use different line endings, which is important considering template literals allow multiline strings.

    // failed in iOS
    fetch(`https:///
    ?param1=${param1}
    ¶m2=${param2}`);
    
    // consistently works
    fetch(`https:///?param1=${param1}¶m2=${param2}`);
    

提交回复
热议问题