zach.codes

zach.codes

Share this post

zach.codes
zach.codes
Human Readable AJAX Requests
Copy link
Facebook
Email
Notes
More

Human Readable AJAX Requests

Zach Silveira
Dec 09, 2016
∙ Paid

Share this post

zach.codes
zach.codes
Human Readable AJAX Requests
Copy link
Facebook
Email
Notes
More
Share

As a JavaScript developer, you must have seen code like this before:

fetch('/users.json', {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Hubot',
      login: 'hubot',
    }),
  })
  .then(response => response.json())
  .then(json => console.log('parsed json', json))
  .catch(ex => console.log('parsing failed', ex))

Anyone who claims to be a web developer knows that fetch is the new standard for making http requests from JS. Last week, I came up with an idea to wrap this api in something that is easily readable and sharable. What if we could turn the code above into text form?

If you inspect any page in Chrome, you can switch to the network tab and view the request headers, url, etc. This is shown under the general tab:

Request URL:http://test.app/settings/user/19
Request Method:PATCH
Status Code:200 OK
Remote Address:192.168.10.10:80

If you scroll down, there's a request payload section showing the body of the…

Keep reading with a 7-day free trial

Subscribe to zach.codes to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Zach Silveira
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More