Is there a way to make an HTTP request using the Chrome Developer tools without using a plugin like POSTER?
This question is related to
google-chrome
google-chrome-devtools
Keeping it simple, if you want the request to use the same browsing context as the page you are already looking at then in the Chrome console just do:
window.location="https://www.example.com";
if you use jquery on you website, you can use something like this your console
$.post(_x000D_
'dom/data-home.php',_x000D_
{_x000D_
type : "home", id : "0"_x000D_
},function(data){_x000D_
console.log(data)_x000D_
})
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
_x000D_
If your web page has jquery in your page, then you can do it writing on chrome developers console:
$.get(
"somepage.php",
{paramOne : 1, paramX : 'abc'},
function(data) {
alert('page content: ' + data);
}
);
Its jquery way of doing it!
$.post(_x000D_
'dom/data-home.php',_x000D_
{_x000D_
type : "home", id : "0"_x000D_
},function(data){_x000D_
console.log(data)_x000D_
})
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
_x000D_
To GET requests with headers, use this format.
fetch('http://example.com', {
method: 'GET',
headers: new Headers({
'Content-Type': 'application/json',
'someheader': 'headervalue'
})
})
.then(res => res.json())
.then(console.log)
I had the best luck combining two of the answers above. Navigate to the site in Chrome, then find the request on the Network tab of DevTools. Right click the request and Copy, but Copy as fetch instead of cURL. You can paste the fetch code directly into the DevTools console and edit it, instead of using the command line.
Expanding on @dhfsk answer
Here's my workflow
I've built javascript-snippet (which you can add as browser-bookmark) and then activate on any site to monitor & modify the requests. :
For further instructions, review the github page.
I know, old post ... but it might be helpful to leave this here.
Modern browsers are now supporting the Fetch API.
You can use it like this:
fetch("<url>")
.then(data => data.json()) // could be .text() or .blob() depending on the data you are expecting
.then(console.log); // print your data
ps: It will make all CORS checks, since it's an improved XmlHttpRequest
.
Source: Stackoverflow.com