Unexpected token ‘<' in JSON

Laraship QuestionsCategory: TechnicalUnexpected token ‘<' in JSON
Luis Wenus asked 4 years ago
I figured this one out myself, but this can cause a LOT of headaches.  If payment isn't working and you get an error saying: "Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 177" at the end of your checkout, this is the solution: The issue is the DEBUGBAR, make sure to set DEBUGBAR_ENABLED to false in .env before attempting the payment API's as for some weird reason the JSON response gets appended with the code from the debugbar and thereby the JSON contains HTML and JS and cannot be converted to JSON.  Cost me a full day of work figuring this out, so hope this can help others and the developers of Laraship. 
Question Tags:
1 Answers
Best Answer
laraship Staff answered 4 years ago
Thanks, Luis, Actually this can be caused by any additional output to the response that breaks the json format and will prevent the frontend from parsing it