Postman App&Postman Interceptor
-
安装Postman
-
安装chrome extension Postman Interceptor
-
chrome上点击Postman Interceptor同步cookie, Postman App上Enable Interceptor
Chrome Console
有时chrome抽风,调试时只能打开无痕窗口,无痕模式下不能使用chrome扩展插件,无法利用Postman Interceptor同步cookie到Postman,此时只能在chrome console下利用js发送http请求,此时发送的请求会自动带上当前窗口的cookie信息。
Get
var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'url', true); //打开连接
httpRequest.send(); //发送请求,请求参数方url中
console.log(httpRequest);
Post
kv格式参数:
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'url', true);
httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");//设置请求头 注:post方式必须设置请求头(在建立连接后设置请求头)
httpRequest.send('p1=v1&p2=v2');
console.log(httpRequest);
json格式参数:
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', 'url', true);
httpRequest.setRequestHeader("Content-type","application/json");
httpRequest.send(JSON.stringify(obj));