const onAddNamePress = async (data: any) => {
setFullName(data.fullname)
navigation.navigate(‘AddGender’, { name: fullName })
}
Here I’m just sending params name to AddGender screen but when I clicked once, no params is sent and I must goback and click again for make it fine.
I should do the same process when I use axios to request Api.
Is it a bug or my code has problem ?
Hey @lordisasi, this doesn’t seem a Dev Client issue.
You’ll have to ensure that data.fullname
is available before pressing the button and triggering onAddNamePress
. When the value is available, the params will be available on the second screen.
Thanks.
Here is my login method and I still get the same error.
const login = async (email, password) => {
setIsLoading(true)
await axios.post(${BASE_URL}/users/login
, {
email,
password
},
{
headers: {
“Content-Type”: “application/json”,
Accept: ‘Application/json’,
}
})
.then(res => {
let userInfo = res.data;
console.log(userInfo);
setUserInfo(userInfo);
AsyncStorage.setItem(‘userInfo’, JSON.stringify(userInfo));
setIsLoading(false);
ToastAndroid.showWithGravity(${email} s'est connecté avec succès
, ToastAndroid.LONG, ToastAndroid.BOTTOM)
navigation.navigate(‘Root’)
})
.catch(error => {
setIsLoading(false);
ToastAndroid.showWithGravity(${JSON.stringify(error.response.data.message) || "Une erreur s'est produite\nReéssayez"}
, ToastAndroid.LONG, ToastAndroid.BOTTOM)
error.response.data ? console.log(Login Error ${JSON.stringify(error.response.data)}
) : console.log(error);;
})
}
I still get the same problem
In the above code you shared, I don’t see any params passed through naivgation.navigate()
method.
It’s kinda hard to see where the problem might be. I’d suggest you share a minimal reproducible example so that I can clone it and run it on my end.
Here I get the same problem using axios.post() … after that, I must click two time before sending data to API