A Guide to Debugging JavaScript in Postman
Getting started with writing JavaScript code for API tests is not easy. Let’s explore some of the most common errors you might encounter while using Postman.
Published in
3 min readSep 28, 2021
Last updated: February 2023
Empty response — JSONError: No data, empty input at 1:1
Receiving an empty response from the API and trying to parse it as JSON will fail with this error:
JSONError: No data, empty input at 1:1 ^
Since there is no content, it makes little sense to parse it. In this case, make sure you test for the status code:
pm.test("Status code is 204", () => { pm.response.to.have.status(204);});
You can also check that the response is indeed empty (if this is the expected behavior).
pm.test("Empty response", () => { pm.expect(pm.response.text()).to.eql('');});
If you find this post…