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
Choose a base branch
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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link

@kevinegami kevinegami Nov 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link

@kevinegami kevinegami Nov 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants