I am using
"expo": "~51.0.28",
"react-native": "0.74.5",
and when I try to fetch method in the giving code I am getting an error network request error.IOS working fine but when it comes to the android I am getting error. What can it be the reason if you help I m glad that I m stuck on this about a week.
I’m using SQL server and my api is public certificated SSL.
I am running on development build.
android:usesCleartextTraffic=”true” this didnt help what else can be solve the problem.
export const login = createAsyncThunk("user/login", async ({email, password}, { rejectWithValue }) => {
try {
console.log(email);
console.log(password);
const response = await fetch(
"https://trendpiyasaapi.pazaryericonverter.com/v1/api/Auth/login/",
{
method: "POST",
headers: {
'Accept': 'application/json',
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
password,
}),
}
);
console.log("58. line login: ", response);
const json = await response.json();
if (!response.ok) {
return rejectWithValue(json);
}
const accessToken = json.data.accessToken;
console.log(accessToken, "Access token from login");
await AsyncStorage.setItem("UserData", accessToken);
console.log("70. line login function:",json);
return json;
} catch (err) {
console.log("line 72 userSlice:", err);
return rejectWithValue({ message: "Network Error" }); // Handle network errors
}
});