1fetch('https://jsonplaceholder.typicode.com/todos/1')
2 .then(response => response.json())
3 .then(json => console.log(json))
1fetch('https://jsonplaceholder.typicode.com/todos/1')
2 .then(response => response.json())
3 .then(json => console.log(json))
4
1// fetch format
2fetch('https://jsonplaceholder.typicode.com/posts', {
3 method: 'POST',
4 body: JSON.stringify({
5 title: 'foo',
6 body: 'bar',
7 userId: 1,
8 }),
9 headers: {
10 'Content-type': 'application/json; charset=UTF-8',
11 },
12})
13 .then((response) => response.json())
14 .then((json) => console.log(json));
1{
2 "userId": 1,
3 "id": 1,
4 "title": "delectus aut autem",
5 "completed": false
6}