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 }));
}
Also in JavaScript:
- install vue-cli
- remove last comma from string javascript
- how to push mutual array elements in an array nested loop javascript
- service worker.js
- react redux counter tutorial
- find and replace value in array of objects javascript
- how to update node
- open lightbox in backend
- how to print in js
- js remove readonly attribute
- create a json object in javascript
- update to node 12 mac
- js get last element of array
- Write Number in Expanded Form
- javascript sort alphabetically
- get child element by class javascript
- javascript include a js file from another
- js format urcurency
- console log all events
- express validator example
- js make radio checked
- javascript sort chars in string
- javascript check if argument is passed
- js api call