Solved it. You have to put the machines IP address not localhost. For me its the standard my wi-fi gives to the local devices. pretty silly but it works except it doesn't. All the routes with push refuses to work also.
Ionic Android emulator doesn't do API calls.
I'm trying to login using Ionic emulator. I have installed Android studio with SDK (Pixel 4) everything starts fine, sometimes (very unstable) but when i try to login it seems like its not doing any API calls. I have no idea how to debug it too because i cant access the console in the emulator. I have the toaster who should display any errors but all i see is the spinner for 0.1sec and nothing happens. I tried to change my BASE_URL from localhost to the local ip address 127.0.0.1:8000 but doesn't work. I checked the CORS.php in Laravel but i dont use sanctum so it doesn't seem to be the issue. Any suggestions what might be wrong or how to debug it in the emulator. Web works perfectly with token stored and all.
const onLogin = async () => {
store.clearErrors()
data.loading = true
try {
const response = await axios.post(`${BASE_URL}/user/login`, data.user)
data.loading = false
if(response.data.error) {
toast.error(response.data.error)
}else {
store.setCurrentToken(response.data.currentToken)
store.setCurrentUser(response.data.user)
toast.success(response.data.message)
router.push('/dailyoffers')
}
} catch (error) {
data.loading = false
if (error.response.status === 401) {
toast.error('Invalid credentials or account not activated')
} else {
toast.error('An error occurred while logging in')
}
store.setErrors(error.response.data.errors)
}
}
Please or to participate in this conversation.