Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 使用多集cookie响应本机fetch/XMLHttpRequest post请求_React Native_Xmlhttprequest_Fetch Api - Fatal编程技术网

React native 使用多集cookie响应本机fetch/XMLHttpRequest post请求

React native 使用多集cookie响应本机fetch/XMLHttpRequest post请求,react-native,xmlhttprequest,fetch-api,React Native,Xmlhttprequest,Fetch Api,我想从web服务器接收多个设置Cookie值。 目前,我只收到标题中的最后一组Cookie。 XMLHttpRequest: var formData = new FormData(); formData.append('userId', state.userId); formData.append('password', state.password); var http = new XMLHttpRequest(); var url = "http://myurl"; http

我想从web服务器接收多个设置Cookie值。 目前,我只收到标题中的最后一组Cookie。
XMLHttpRequest:

 var formData = new FormData();
 formData.append('userId', state.userId);
 formData.append('password', state.password);

 var http = new XMLHttpRequest();
 var url = "http://myurl";
 http.open("POST", url);
 http.setRequestHeader("Content-type", "multipart/form-data");
 http.withCredentials = true;
 http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        console.log(http.responseText);
        console.log(http.getAllResponseHeaders());
    }
}
http.send(formData);
获取:

fetch('http://myurl', {
    method: 'POST',
    headers: {
    'Content-Type': 'multipart/form-data',
  },
    credentials: 'same-origin',
    body: formData
 })
 .then((response) => {
   console.log(response);
   console.log(response.headers.getAll('set-cookie'));
   return response.json()
 })
 .then((responseJson) => {
    console.log('responseJson', responseJson);
    console.log('formData', formData);
    setLoginBool(responseJson.success);
 })
 .catch((error) => {
    console.error(error);
 });
我已经添加了邮递员请求的结果和获取结果的日志。 似乎只接收到最后一组Cookie值。

您找到解决方案了吗?我这里也有同样的问题。我解决这个问题的方法是在react本机代码中使用“credentials:“same origin”。