-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Hi,
I've tried to make a plugin, just like this one https://github.com/apicase/jsonapi
Copy/pasted the code, just changed normalization func. And the doRequest() stopped working.
When mergeOptions() happens the options get "normalized" (not sure what for). After this process the opts array looks like this:
0: {_isNormalized: true, adapter: {…}, payload: {…}, meta: {…}, options: {…}, …}
1: {_isNormalized: true}
...
Then this array is being reduced by this func - return payloadMerger(res, cur.payload);
So the 2nd item (index 1) in the array is breaking the merge logic, as there is no "payload" value.
The error is "Cannot read property 'url' of undefined" in this snippet happens, because "to" is undefined.
merge(from, to) {
const res = Object.assign({}, from, to)
if (to.url !== undefined && from.url !== undefined) {
res.url = to.url[0] === '/' ? to.url : [from.url, to.url].join('/')
}
return res
}
Definig hook locally in ApiService works as intended.