Quick and Dirty API endpoint testing using devtools console.

January 2, 2022 note-to-self

Sometimes I'd be on a client network, without access to tools like Postman. But, I'd want to test and endpoint to see what's what. So, a little hackery with the devtools console and I'm good:

// Post to an endpoint in chrome devtools using the fetch api

fetch('http://domain.com/v1/api/library', {
  method: 'POST',
  body: "Search[id]=ZZZ00186&token=OPKEP8UQS8-Mv5VZzVuzTyicI_dp1D1cEXfO9Muwr&Search[size]=25",
  headers: {
    'Content-type': 'application/x-www-form-urlencoded'
  }
})
.then(res => res.json())
.then(console.log)

Note: I took the example from a version of the "API" (airquotes!) that actually was an application/x-www-form-urlencoded POST action. IOW, not really a classic "endpoint".