react making 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:
- javascript remove css link
- leafletjs openstreets example
- javascript the difference between innerText vs. innerHTML vs. textContent
- javascript check if boolean is undefined
- empty array length javascript
- create bottom navigation bar react native
- javascript join 2 variables into string
- javascript substring after character
- indexof()
- how to modify an array
- receive blob over jquery ajax
- javascript style
- how to install all needed modules in node
- javascript refresh page automatically
- react transition group
- get url of page in background script
- event when variable value changes javascript
- copy array javascript
- js class static function
- puppeteer js
- how to make a variable equal something in a array javascript
- copy to clipboard angular
- javascript string includes
- async await anonymous function