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));