Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.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
Reactjs 如何从react native中的标题访问x-auth?_Reactjs_React Native_Xauth - Fatal编程技术网

Reactjs 如何从react native中的标题访问x-auth?

Reactjs 如何从react native中的标题访问x-auth?,reactjs,react-native,xauth,Reactjs,React Native,Xauth,我试图从服务器访问x-auth令牌,但没有得到预期的结果。服务器的response.headers的控制台输出如下 Headers { map: { connection: "keep-alive" content-type: "application/json; charset=utf-8" x-auth: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiIxaXBpNG1laiIsImFjY2VzcyI6I

我试图从服务器访问
x-auth
令牌,但没有得到预期的结果。服务器的
response.headers
的控制台输出如下

  Headers { 
    map: {
    connection: "keep-alive"
    content-type: "application/json; charset=utf-8"
    x-auth: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiIxaXBpNG1laiIsImFjY2VzcyI6ImF1dGgiLCJpYXQiOjE1NTY3MDg1NTR9.cOXtbQO_n2vf-HwLmKwyzSi9QcFgh4SghfgCamcLyw4"
    x-powered-by: "Express"
}
    }
我曾尝试控制台
x-auth
但出现错误
未定义auth
。但当我控制台
response.headers.map.connection
时,我得到了值。以下是我迄今为止尝试的代码

fetch(GLOBAL.LOGIN, {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                "requestHeader": {
                    type: "login"
                },
                "loginData": {
                    email_id: this.state.email_id,
                    password: this.state.password
                }
            })
        }).then((response) => {
           console.log(response.headers.map.x-auth);
        })

我不知道如何访问令牌。请帮助。

在您的处理程序中。然后您应该能够访问如下标题元素:

console.log(response.headers.get("x-auth"));

在.then处理程序中,您应该能够访问如下标题元素:

console.log(response.headers.get("x-auth"));