Data not being sent Axio post request from React Native to Spring Boot API

When I am trying to make axio post request from React native to my Spring Boot API, my data is not being sent?

Here is my code in apiReq function:

const apiReq = () => {   return (axios.post('http://{IP address}:8082/api/login', {      headers: {       "Accept": 'application/json',       "Content-Type": "application/json"     },     body: JSON.stringify({       "password": "#####",       "username": "abcd.gmail.com"     })   })     .then(response => {        console.log(response.data.responseMessage.errorCode);      })     .then(result => console.log(result))     .catch(error => console.log('error', error))   )  } 
Add Comment
1 Answer(s)

Maybe, you don’t use JSON stringfy. Also, I use axios like that.

const body = {       password: "#####",       username: "abcd.gmail.com"     } const options = {     headers: {           "Accept": 'application/json',           "Content-Type": "application/json"     } }  axios.post('http://{IP address}:8082/api/login', body, options) .then(response => console.log(response)) .catch(err => console.log(err)); 
Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.