Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Unexpected token error #2

Open
wants to merge 1 commit into
base: master
from

Conversation

@Shwetajain148
Copy link

@Shwetajain148 Shwetajain148 commented Nov 20, 2018

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!

console.log(result.response);
}
});
if (res.statusCode === 200) {

This comment has been minimized.

@kevinegami

kevinegami Nov 30, 2018

Is 200 response and response.ok equivalent? If so, then we only need one of them to run context.succeed?

This comment has been minimized.

@Shwetajain148

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.

This comment has been minimized.

@kevinegami

kevinegami Nov 30, 2018

So we can get a 200 status code but response.ok !== True? Seems odd for an API.

This comment has been minimized.

@kevinegami

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.