I'm working on a React Native project where I need to display images fetched from an API that requires an authorization token for authentication. I'm currently using the Image component from React Native to render the images, but I'm unsure how to pass the authorization token along with the image requests.
I have the authorization token stored in my application's state, and I'm wondering how I can include it in the image requests. Is there a way to append the token to the image URL or include it as a header in the request?
Here's an example of how I'm currently using the Image component:
import React from 'react';
import { Image } from 'react-native';
const MyComponent = () => {
const authToken = 'myAuthorizationToken';
return (
<Image
source={{ uri: 'https://example.com/image.jpg' }}
style={{ width: 200, height: 200 }}
/>
);
};
export default MyComponent;
Any help or guidance on how to include the authorization token with the image requests would be greatly appreciated. Thank you!