Skip to content

Commit

Permalink
Fix regression in vuex-rest-api v2.13.0 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pchisholm authored Apr 20, 2021
1 parent 1dafd24 commit c587e9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dist/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,19 @@ var Resource = /** @class */ (function () {
}
// This assignment is made to respect the priority of the base URL, url, method.
// It is as following: baseURL > axios instance base URL > request config base URL
var method = options.method;
var fullRequestConfig = Object.assign({
method: options.method,
method: method,
url: urlFn(params),
baseURL: _this.normalizedBaseURL,
}, tmpRequestConfig);
// In v2.13.0 a regression was introduced that was allowing data to be passed along with GET requests,
// this has the unintended side effect of setting content-type: application/json;charset=UTF-8 headers and
// is an unwanted side effect. This is the least intrusive way of handling this problem for now, but I don't
// think we really even need a default data prop in this flow.
if (["post", "put", "patch"].indexOf(method.toLowerCase()) === -1) {
delete fullRequestConfig.data;
}
return _this.axios.request(fullRequestConfig);
},
property: options.property,
Expand Down
11 changes: 10 additions & 1 deletion src/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,20 @@ export class Resource {

// This assignment is made to respect the priority of the base URL, url, method.
// It is as following: baseURL > axios instance base URL > request config base URL
const method = options.method as AxiosRequestConfig["method"]
const fullRequestConfig = Object.assign({
method: options.method as AxiosRequestConfig["method"],
method,
url: urlFn(params),
baseURL: this.normalizedBaseURL,
}, tmpRequestConfig)

// In v2.13.0 a regression was introduced that was allowing data to be passed along with GET requests,
// this has the unintended side effect of setting content-type: application/json;charset=UTF-8 headers and
// is an unwanted side effect. This is the least intrusive way of handling this problem for now, but I don't
// think we really even need a default data prop in this flow.
if (["post", "put", "patch"].indexOf(method.toLowerCase()) === -1) {
delete fullRequestConfig.data;
}
return this.axios.request(fullRequestConfig)
},
property: options.property,
Expand Down

0 comments on commit c587e9b

Please sign in to comment.