You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Usage of fetch fails when it calls the native module RCTDataManager internally with the error NSString cannot be converted to NSDictionary.
The 2nd parameter to the queryData of RCTDataManager used to be of type id, and the string argument was converted to an NSDictionary inside the method. With this commit 096f1d9#diff-de4fcf6f89a511746ac81765638915b3R26 it has been changed. The method now accepts an NSDictionary as 2nd parameter, but receives an NSString. Thus it breaks. @amasad you merged in those changes - can we maybe have the old version back? ;) I couldn't figure out where the arguments are actually passed from JS-land to Obj-c-land but I assume data is always being passe around as strings and thus this fails?
Sorry about the breakage. AFAIK, RCTDataManager is a private implementation detail of XMLHttpRequest, which now passes the data as a dictionary, so I'm not sure why it would be breaking.
Can you give me any more detail about where the error is occurring?
@nicklockwood Nope not doing anything of that kind. I just do fetch('someurl') and that's it. It happens with a vanilla 0.3.11 pulled from npm. Also I'm not the only person who has this issue. At least one other person on IRC had the same issue.
@johanneslumpe I'm unable to explain how that can be happening. fetch calls XMLHttpRequest, and XMLHttpRequest sends an object as the second parameter to queryData, not a string. Can you verify that the queryData call in your local copy of XMLHttpRequest.ios.js looks like this?
RCTDataManager.queryData(
'http',
{
method: method,
url: url,
data: data,
headers: headers,
},
// TODO: Do we need this? is it used anywhere?
'h' + crc32(method + '|' + url + '|' + data),
(result) => {
result = JSON.parse(result);
this.callback(result.status, result.responseHeaders, result.responseText);
}
);
If so, can you trace the call in Chrome debugger and verify that's the method being called? Maybe you somehow have a stale copy of XMLHttpRequest.ios.js in another folder that it's using preferentially?
RCTDataManager.queryData('http',{method: method,url: url,data: data,headers: headers,},// TODO: Do we need this? is it used anywhere?'h'+crc32(method+'|'+url+'|'+data),(result)=>{result=JSON.parse(result);this.callback(result.status,result.responseHeaders,result.responseText);});
@nicklockwood Solved it. Thanks for the hint with the stale copy. Turns out I had a module installed, which had its own react-native copy in node_modules. Weird though that that version was used and not my top-level one.
react-native-video because I was developing on it. Was my own fault because I npm installed in the module, while i was deving on it. But I do not understand why the packager chose the nested react-native over the top level one. Maybe it has something to do with node's resolve algorithm.
Activity
frantic commentedon Apr 14, 2015
Blames to "Implemented response headers when using
XMLHttpRequest" by @nicklockwood that is based on #382nicklockwood commentedon Apr 14, 2015
Sorry about the breakage. AFAIK, RCTDataManager is a private implementation detail of XMLHttpRequest, which now passes the data as a dictionary, so I'm not sure why it would be breaking.
Can you give me any more detail about where the error is occurring?
nicklockwood commentedon Apr 14, 2015
Yep, it looks like the only reference to DataManager is in XMLHttpRequest.ios.js, where it is passing a dictionary for the second parameter.
Are you using an outdated copy of XMLHttpRequest.ios.js? Or maybe you wrote some custom js code that calls DataManager directly, and passes a string?
johanneslumpe commentedon Apr 15, 2015
@nicklockwood Nope not doing anything of that kind. I just do
fetch('someurl')and that's it. It happens with a vanilla 0.3.11 pulled from npm. Also I'm not the only person who has this issue. At least one other person on IRC had the same issue.nicklockwood commentedon Apr 15, 2015
@johanneslumpe I'm unable to explain how that can be happening. fetch calls XMLHttpRequest, and XMLHttpRequest sends an object as the second parameter to queryData, not a string. Can you verify that the queryData call in your local copy of XMLHttpRequest.ios.js looks like this?
If so, can you trace the call in Chrome debugger and verify that's the method being called? Maybe you somehow have a stale copy of XMLHttpRequest.ios.js in another folder that it's using preferentially?
johanneslumpe commentedon Apr 15, 2015
Local queryData looks like this:
johanneslumpe commentedon Apr 15, 2015
@nicklockwood Solved it. Thanks for the hint with the stale copy. Turns out I had a module installed, which had its own react-native copy in
node_modules. Weird though that that version was used and not my top-level one.frantic commentedon Apr 15, 2015
Nice catch! What was the module name?
On Wed, Apr 15, 2015 at 7:06 AM Johannes Lumpe notifications@github.com
wrote:
johanneslumpe commentedon Apr 15, 2015
react-native-videobecause I was developing on it. Was my own fault because Inpm installedin the module, while i was deving on it. But I do not understand why the packager chose the nestedreact-nativeover the top level one. Maybe it has something to do with node's resolve algorithm.