Snippet to fetch remote REST API and display in Console of Chrome DevTool

lockevn
Aug 21, 2020

Open your Chrome DevTools., sometime you found a wonderful REST API and want to see it in action, with several changes in the REST arguments.

Here is a gist to fetch result from https://jsonplaceholder.typicode.com/posts (feel free to change it)

and display it right in the Console

// GET:
const response = await fetch('https://jsonplaceholder.typicode.com/posts')
console.log(await response.json())
// POST
let r = await fetch('https://jsonplaceholder.typicode.com/posts', {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ lockevn: 1 }),
})
console.log(await r.json())

This help me a lot of time, but I always forget how to get `json()` from response, hahaha

--

--

lockevn

Developer, Sportman. Write code with joy, bake app with heart. Opinions are my own. If you feel I save your time, go http://BuyMeACoff.ee/Lockevn