-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix(request): Set GET as default request method #50
Conversation
@@ -37,7 +37,7 @@ const _tryParseJSON = (res: Response): Promise<any> => { | |||
*/ | |||
export const _fetchJSON = ( | |||
url: string, | |||
{headers, method, mode, ...options}: RequestInit = {} | |||
{headers = {}, method = 'GET', mode, ...options}: RequestInit = {} |
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.
Another way to accomplish this would be to update the if below to match how we do it internally.
if (method && method !== 'GET') {
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.
Probably should go with the other way. Otherwise a lot of internal code would break.
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.
Internally, we also default it, but we do it later in this function. I would imagine the internal function was written pre-es6 defaults
Are we good to merge this? |
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.
Looks good. We should test it in our apps too
Sounds good I will bump in core in the AM. |
🎉 This PR is included in version 1.0.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
As mentioned in #49, query params were being ignored when passed in via the SDK.
I investigated and found that this was due to our default of the
Content-Type
header. The defaulting was put in place to handlePOST
but since method is undefined it was also being set for impliedGET
requests.How Has This Been Tested?
Tests have been updated. I also verified that setting get will address query params not being parsed properly on the backend.
Screenshots (if appropriate):
Checklist:
yarn validate
to ensure that tests, typescript and linting are all in order.resolves #49