Home > OS >  Axios triggering weird in React native app
Axios triggering weird in React native app

Time:02-01

Hello i have a weird thing going on,im using axios in order to send post-get http request for my app.The thing is that axios in my pc working good but in my laptop need console.log("") before axios request i dont know why.This happens in all my files.

It gives me this error : Possible Unhandled Promise Rejection (id : 0 ): [Axios error: Request failed with statis code 404]

Here is my code :

  function getProfile(){
    try{
      //console.log("") <-------------------------- Here i put it
      axios.post(URL '/checkData',
      {
        usernameCheckAXIOS : username,
        passwordCheckAXIOS : password, 
      })
      .then((response)=>{
        console.log(response.data)
        setProfile(response.data);

        if(response.data.responseOfProfile == false){
          Alert.alert("Access Dinied")
        }
        else{
          navigation.navigate('Home')
        }

      })
    }catch(error){}

  }

CodePudding user response:

[Axios error: Request failed with statis code 404] is an error URL not found.

Are you sure that the url URL '/checkData' is valid ?

CodePudding user response:

If you are getting a “Possible unhandled promise rejection” warning in your React Native app, it means that a promise was rejected, but the rejection was not handled. Promises in JavaScript are used to handle asynchronous operations, and they can either be resolved or rejected.

axios.post(URL '/checkData',
  {
     usernameCheckAXIOS : username,
     passwordCheckAXIOS : password, 
  })
.then((response)=>{
  //... your code
})
.chatch(error => console.log(error)) // <-- add this line

The HTTP 404 Not Found response status code indicates that the server cannot find the requested resource

so verify your URL, should be invalid because it cannot be found.

  • Related