browniefed / examples

Egghead Screencast Code Examples
203 stars 102 forks source link

I have a problem fetching record from API using Axios. #20

Open abdojulari opened 5 years ago

abdojulari commented 5 years ago

I have trouble doing this as I am very new to react and react native. I am trying to use axios to fetch record from API. I have attached the POSTMAN screenshot. The first issue I have is the grant_type in the body of the postman and second is how to change the username and password to accept the inputs from the user. `componentDidMount(){ const data={ grant_type: 'password', client_id:'RxPadApp', username: this.state.username, password: this.state.password,

     }
     axios.post('http://192.168.210.159:3000/api/2019/token',
         data
     )
     .then((response)=>{
         console.log(response);
     }).catch((error)=>{
         console.log(error);
     });
 }

screenshot 2019-02-05 at 1 52 32 pm `