使用Cookie反应本机图像uri请求

Ret*_*n-1 1 react-native react-native-image

我为我的应用程序使用了基于会话的身份验证系统,但是我的API调用工作得很好,但是,当使用以下请求图像时:

<Image source={{uri: 'https://facebook.github.io/react/logo-og.png'}}
       style={{width: 400, height: 400}} />
Run Code Online (Sandbox Code Playgroud)

该请求未通过身份验证

但是,需要身份验证才能检索图像。您将如何处理?似乎没有关于此的任何文档

bas*_*ase 5

您可以通过Image source 传递标题

<Image source={{
    uri: 'https://facebook.github.io/react/logo-og.png', 
    headers: {
        Cookie: 'cookie data here',
    }
}}>
Run Code Online (Sandbox Code Playgroud)

从API响应中获取Cookie:

fetch('apicall').then(res => {
    cookieData = res.headers.map["set-cookie"];
})
Run Code Online (Sandbox Code Playgroud)