Answers for "send post request in react"

12

react post request

componentDidMount() {
    // Simple POST request with a JSON body using fetch
    const requestOptions = {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ title: 'React POST Request Example' })
    };
    fetch('https://jsonplaceholder.typicode.com/posts', requestOptions)
        .then(response => response.json())
        .then(data => this.setState({ postId: data.id }));
}
Posted by: Guest on May-22-2020
3

how to send axios delete to the backend reactjs

axios.delete(URL, {
  headers: {
    Authorization: authorizationToken
  },
  data: {
    source: source
  }
});
Posted by: Guest on February-15-2020
0

angularjs make post request

var url = 'posturl', data = 'parameters',config='contenttype';

$http.post(url, data, config).then(function (response) {

// This function handles success

}, function (response) {

// this function handles error

});
Posted by: Guest on February-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language