Uncaught SyntaxError: Unexpected token u in JSON at position 0

前端 未结 7 1449
[愿得一人]
[愿得一人] 2020-12-03 00:11

Only at the checkout and on individual product pages I am getting the following error in the console log:

VM35594:1 Uncaught SyntaxError: Unexpected token u          


        
7条回答
  •  感情败类
    2020-12-03 00:56

    As @Seth Holladay @MinusFour commented, you are parsing an undefined variable.
    Try adding an if condition before doing the parse.

    if (typeof test1 !== 'undefined') { test2 = JSON.parse(test1); }

    Note: This is just a check for undefined case. Any other parsing issues still need to be handled.

提交回复
热议问题