-
Notifications
You must be signed in to change notification settings - Fork 7
Handle text API responses #223
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
Conversation
Mudaafi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, just one comment.
Note: the
trackConversiontest for custom_type is currently failing due to Backend changing the error response.
| fetchSpy = sinon.spy(() => Promise.resolve({ | ||
| ok: false, | ||
| status: 429, | ||
| statusText: 'Too Many Requests', | ||
| headers: new Map([['content-type', 'text/plain']]), | ||
| text: () => Promise.resolve('Too many requests'), | ||
| })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the mock here
src/modules/tracker.js
Outdated
| }).catch((error) => { | ||
| instance.eventemitter.emit('error', { | ||
| url, | ||
| method, | ||
| message: `Error reading text: ${error.message}`, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we standardize the the error handling for these two paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mudaafi Sorry what do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I meant that we catch and emit the error for .json() and .text() very similarly. Possibly something we can extract into a handler function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. You're right. Let me do that
Mudaafi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, thanks for doing the refactor. If @esezen has some time to look over the changes just so we didn't miss anything, that'd be great.
esezen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Why?
Content-Typeheader before processing the responseThe screenshot shows an example of the API response for 429 response