Technical Articles
Testing API Calls using your Edge/Chrome
This is for those times when a single instance of an API call needs to be tested. Sometimes, API testing tools are not available or extensions to browsers are not permitted in the environment. In some instances, this neat little code below can help in a pinch. It can be executed in the console of Chrome or Edge Developer Tools which isĀ generally available.
fetch('https://myapiurl.com/post', {
method: 'POST',
body: JSON.stringify({
examplefield1: 'zzz',
examplefield2: 'yyy',
}),
headers: {
'Content-type': 'application/json; charset=UTF-8'
}
})
.then(res => res.json())
.then(console.log)
credit to the good people in Stack Overflow : Making HTTP Requests using Chrome Developer tools – Stack Overflow
Be the first to leave a comment
You must be Logged on to comment or reply to a post.