我正在为我的应用程序使用基于会话的身份验证系统,但是,当使用以下方法请求图像时,我的API调用工作得非常好:
<Image source={{uri: 'https://facebook.github.io/react/logo-og.png'}} style={{width: 400, height: 400}} />
请求未经身份验证
但是,检索图像需要身份验证。你会怎么做?似乎没有任何具体的文件
你可以通过 headers 使用图像源:
<Image source={{ uri: 'https://facebook.github.io/react/logo-og.png', headers: { Cookie: 'cookie data here', } }}>
从API响应中获取cookie:
fetch('apicall').then(res => { cookieData = res.headers.map["set-cookie"]; })