In the challenge of Day 29, when I run the ‘echo’ request after creating and triggering the webhook, the console shows an error stating "JSONError: Unexpected token u in JSON at position 0".
Other than that everything works fine.
Can anyone help me with this?
In the screenshot, the collection runner says that the error is within the pre-request script for the request called echo. Are you able to share your pre-request script?
Hello @neilstudd ,
I have attached the screenshots of pre-request script and test script below.
The pre-request script doesn’t look quite right to me.
You might need to go back and take a look at what the documentation says to add in there.
Are you suppose to manually run that one or the
trigger webhook request that uses that request.
Probably best to read each part of the documentation, it will guide you through each step.
I completed this scenario today using it so it definitely works
Danny is correct; you’re not supposed to trigger this particular request manually (I see the same error in my Day 29 collection if I attempt to run it directly).
There’s another clue in the error message: When you see Unexpected token u in JSON this normally means that you’re trying to do
JSON.parse on a variable that does not exist (the value is literally “undefined”, so when it tries to convert this to JSON, the first character it encounters is “u”). You can see proof of this if you add
console.log(globals.previousRequest) at the top of the script -
You should review the documentation for Day 29, and check that you are running the correct requests at the correct time