Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Handling Unexpected token error #2
Conversation
| console.log(result.response); | ||
| } | ||
| }); | ||
| if (res.statusCode === 200) { |
kevinegami
Nov 30, 2018
Is 200 response and response.ok equivalent? If so, then we only need one of them to run context.succeed?
Is 200 response and response.ok equivalent? If so, then we only need one of them to run context.succeed?
Shwetajain148
Nov 30, 2018
Author
@kevinegami, No, they are not same. res.statusCode only returns numeric status code so the first if check is to match the returned HTTP status code and the second if check is to match the returned parsing result in result variable. The result variable has nothing to do with the 200 response.
@kevinegami, No, they are not same. res.statusCode only returns numeric status code so the first if check is to match the returned HTTP status code and the second if check is to match the returned parsing result in result variable. The result variable has nothing to do with the 200 response.
kevinegami
Nov 30, 2018
•
So we can get a 200 status code but response.ok !== True? Seems odd for an API.
So we can get a 200 status code but response.ok !== True? Seems odd for an API.
kevinegami
Nov 30, 2018
•
I understand there is a status code and a response and they are NOT the same, but for a 200 status code shouldn't they be?
I understand there is a status code and a response and they are NOT the same, but for a 200 status code shouldn't they be?
Hi @dmr-loggly, @kevinegami,
In this PR, I'm handling the code break when parsing the HTML/XML response from server. The script sometime breaks at line #105 when the returned response is not a valid JSON. So I'm allowing parsing only when the success is returned and status code is 200.
Please review and merge. Thanks!