J
J
Jeff_Parker2022-02-23 11:41:57
Node.js
Jeff_Parker, 2022-02-23 11:41:57

How to get payload request data?

I work with one service, which recently started generating a unique session identifier. To work around the problem, I decided to use npm puppeteer . The bottom line is this - a site opens in Chromium, manual authorization occurs, then I select the data parameters on the site itself. After that, in Devtools, you can observe the request body I need 6215f1a20b50a014455103.png
. Since the identifier is generated after entering the site, I did not find a way to get it, except for the above puppeteer
. After receiving the ID, I intend to use it in fetch () and use it to get the necessary Response of the request what i already got
6215f320d9068383673107.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jeff_Parker, 2022-02-23
@Jeff_Parker

The issue was resolved with the following lines of code

await page.on('response', async response => {
   if(response.request().method() === 'POST' && response.request().url() === 
      'https://website.com/'){
      console.log(await response.request()._postData)
   }
})

D
Dimonchik, 2022-02-23
@dimonchik2013

uh... what's the question?
intercept cookies and go:
there are no "sessions"
there are either cookies or POST (rarely) / GET headers (more often, but not as often as cookies) requests
(i.e. logically yes - there are sessions, but this data is intercepted because it is present in the headers or (more rarely) the body of the document)
it’s another matter that tools other than the [headless] browser can really not catch cookies set by JS frameworks,
respectively: either the headless browser intercepts cookies and then normal parsing, or all the time a parser based on such a browser

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question