how to send post request js fetch
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:
- hello world in javascript
- js return a promise
- console in jsfiddle site:stackoverflow.com
- Can't bind to 'formGroup' since it isn't a known property of 'form'
- jquery check if clicked outside div
- pdf to image javascript
- drupal 8 get node from path alias
- how to get focused element in jquery
- javascript all type of data
- js get current seconds
- factorial javascript function
- import { PartialType } from '@nestjs/mapped-types'
- How to Submit Forms and Save Data with React.js
- js date is weekend
- get keys objet javascript
- math js
- react how to export component
- react pass parameters to other page
- call method in javascript
- pd.read_json('data.json') args
- js array from
- aos library animation angular
- javascript project ideas
- total array with function