json beautify
fetch('https://fakestoreapi.com/products?limit=5')
.then(res=>res.json())
.then(json=>console.log(json))fetch('https://fakestoreapi.com/products/1')
.then(res=>res.json())
.then(json=>console.log(json))fetch('https://fakestoreapi.com/products/6',{
method:"DELETE"
})
.then(res=>res.json())
.then(json=>console.log(json))fetch('https://fakestoreapi.com/products')
.then(res=>res.json())
.then(json=>console.log(json)) //output
[
{
id:1,
title:'...',
price:'...',
category:'...',
description:'...',
image:'...'
},
/*...*/
{
id:30,
title:'...',
price:'...',
category:'...',
description:'...',
image:'...'
}
]
fetch('https://fakestoreapi.com/products/7',{
method:"PUT",
body:JSON.stringify(
{
title: 'test product',
price: 13.5,
description: 'lorem ipsum set',
image: 'https://i.pravatar.cc',
category: 'electronic'
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))fetch('https://fakestoreapi.com/products',{
method:"POST",
body:JSON.stringify(
{
title: 'test product',
price: 13.5,
description: 'lorem ipsum set',
image: 'https://i.pravatar.cc',
category: 'electronic'
}
)
})
.then(res=>res.json())
.then(json=>console.log(json))
Also in JavaScript:
- jquery to hide a div
- length of array javascript
- how to trigger events when the document loads in js
- jspdf Cannot create property 'callback' on number '15'
- javascript var in quotes
- npm install save shortcut
- add to set js
- angular bind to class or ngClass
- javascript location redirect
- javascript canvas reset transform
- parsley custom error message
- js script
- lodash merge
- javascript Prevent Object MutationPassed
- jquery detect textarea change
- javascript element by class
- anonymous function javascript
- moving a item fro index to another index, javascript
- jquery ajax upload image
- multiplication of complex numbers javascript
- sort a string in javascript
- adding to array js
- using this to get name of the clicked element
- install node js on raspberry pi