so I'm trying to create a get request to the Google OAuth2 API in React Native using React Query, where I pass in an authorization header and I'm supposed to get basic information about that user, like their name, email, profile pic. The code works and retrieves the data on the Web and Android, but does not work on IOS. As of now, I've tried using different ways of fetching the data, like Axios, instead of the built in fetch function, but it's always stuck on loading.
Here's the code for making the fetch request:
const { isLoading, error, data } = useQuery("userData", async () => {
const response = await fetch(
"https://www.googleapis.com/oauth2/v3/userinfo",
{
method: "GET",
headers: {
Accept: "application/json",
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
}
);
return await response.json();
});
where the access token is retrieved through a useContext call. This is what I return from my component:
return (
<View
style={{
backgroundColor: "green",
flex: 1,
justifyContent: "center",
alignItems: "center",
}}
>
<Text style={{ color: "white" }}>{data.email}</Text>
</View>
);
};