send post request in react code example
Example 1: react post request
componentDidMount() {
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 }));
}
Example 2: how to send axios delete to the backend reactjs
axios.delete(URL, {
headers: {
Authorization: authorizationToken
},
data: {
source: source
}
});
Example 3: angularjs make post request
var url = 'posturl', data = 'parameters',config='contenttype';
$http.post(url, data, config).then(function (response) {
}, function (response) {
});