I am using nightmare to login to a page and click a few links. Then I go to a specific url for which a POST
request is made. I want to retrieve the json response from the POST request.
So far, I have this
var Nightmare = require('nightmare');
const nightmare = Nightmare({ show: true });
nightmare
.goto('https://my.url/')
.type('#user_id', 'myUserId')
.type('#password', 'passw0rd')
.click('#button-login')
.wait(3000)
.goto('specific-url') // this URL loads a page with some data
.end()
.then(console.log) // this prints stuff like HTTP response: OK
.catch((error) => {
console.error('Search failed:', error);
});
When I go to the specific-url
, a POST request is made and the page is populated with data. I can see the page load properly but I want the data in Json format because I don't wanna parse the page.
Any ideas on how to retrieve the response json?