I'm new to react-native I'm sending a request to server and want to get response and body at same block so that I can send both items to an other function my fetch method is looks like
send_request = (data) =>{
url = BASE_URL + "some/url.json"
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
user: {
email: data.email,
full_name: data.name,
}
})
}).then((response) => {
//how can I get response body here so that I can call following method
// this.use_response(responsebody, response.headers)
return response.json()
}).then((responseJson) => {
// or how can I get response headers here so that I can call following fuction
// this.use_response(responseJson, headers)
return responseJson
}).catch((error) => {
console.log(error)
});
}
How can I use both at once please help thanks in advance!