19 lines
464 B
Markdown
19 lines
464 B
Markdown
|
|
|
|
```js
|
|
const response = fetch("http://example.com/movies.json")
|
|
const responseJson = response.json();
|
|
```
|
|
|
|
```js
|
|
const response = fetch(url, {
|
|
method: "POST", // *GET, POST, PUT, DELETE, etc.
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
// 'Content-Type': 'application/x-www-form-urlencoded',
|
|
},
|
|
redirect: "follow", // manual, *follow, error
|
|
body: JSON.stringify(data), // body data type must match "Content-Type" header
|
|
});
|
|
```
|