|
Got tired of dealing with unreadable fetch code when copying from browser DevTools - especially those with long query strings and minified JSON. Built *Fetch Beautifier* to solve this. It formats fetch requests instantly with `Ctrl+Shift+V`. *Before:*
```js
fetch('https://api.example.com/data?userId=123&type=post&limit=10&o...', {
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
},
body: '{"title":"Hello World","content":"This is a test"}',
method: 'POST',
})
``` *After:*
```js
const url = new URL('https://api.example.com/data')
url.search = new URLSearchParams([
['userId', '123'],
['type', 'post'],
['limit', '10'],
['offset', '0'],
]).toString()
fetch(url, {
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
},
body: JSON.stringify({
title: 'Hello World',
content: 'This is a test',
}),
method: 'POST',
})
``` Free on VS Code marketplace. Feedback welcome! https://marketplace.visualstudio.com/items?itemName=rxliuli.... Demo Video:
https://www.youtube.com/watch?v=9SMLOwZwnU0 |