Closed jamesone closed 6 years ago
Try to do it in such way:
req.headers = Object.assign({}, req.headers, headers);
This didn't seem to fix the error. I don't think it's related to the code snippet above ^ 🤔 I commented it out & the error remains.
After investigating this further, I found that removing Object.assign
on line 7 in fetchWithMiddleware
fixes the error.
var _extends = function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
I think this is an issue with react-native not allowing the use of Object.assign in certain scenarios.
How can I go about creating a patch for this?
I had to add the following to fetchWithMiddleware.js
:
function extend(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
I then had to use it here:
return extend({}, res, { payload: payload });
Inside the runFetch
method
I'm getting the following error when trying to use this package on
react-native (0.55.4)
:The simulator is throwing the following error:
You can see the simulator is referencing
fetchWithMiddleware.js (line: 41-13)
Any ideas why this is happening? I've looked everywhere to try and find a solution, none of them work.
I believe it has something todo with a middleware I added, however, commenting this out doesn't fix the error: