Copy variable from network tab preview in Chrome Dev Tools

爱⌒轻易说出口 提交于 2020-04-12 19:45:12

问题


I'm using the Chrome Dev Tools, and I am digging through the network pane to look at an XHR response with the preview tab. I want to grab a specific object from the preview. But when I try to store as global variable by right clicking preview object, the temp variable created was null.

I find that rather strange since the data is in memory (otherwise it wouldn't be displayed at all). Here's an example of a rather large response array that I'm trying to get a specific object from.

To clarify, I can store a variable that appears in my console. But I can't store a variable from the preview pane of the network tab. Is there any feature of the Chrome Dev Tools I'm overlooking, or am I forced to console log my XHR response and pull the object from there?

I'd really rather not add any console.log() or other breakpoints into my code just to have to remove them later. Digging through the super-long raw JSON response is also not practical. I'm using Chrome 47 on Windows 7.


回答1:


I can get it to work by going:

  1. Right click on the array index
  2. "Store as global variable"

Then from the console, typing:

copy(temp1);

And then it will be on the clipboard.




回答2:


Maybe a bit late, but you could go to response tab, copy the response content and then in the console just paste it after :

var response = <<paste here>>

i cant tell by the screenshot but you can then type response.data[64]



来源:https://stackoverflow.com/questions/34530967/copy-variable-from-network-tab-preview-in-chrome-dev-tools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!