Created
May 24, 2018 04:08
-
-
Save ericxyan/2d6caada1d96838315487a34b74c5934 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const $ = cheerio.load(pm.response.text()) | |
const ele = $('form input[type="hidden"]'); | |
const csrf_token = ele.val(); | |
console.log(csrf_token); | |
const loginRequest = { | |
url: 'https://a0f2a3f3-f800-40ba-8578-248561f0b0f8.mock.pstmn.io/login', | |
method: 'POST', | |
header: { | |
'Content-Type': 'application/x-www-form-urlencoded' | |
}, | |
body: { | |
mode: 'urlencoded', | |
urlencoded: [ | |
{key: "username", value: "eryan", diabled: false}, | |
{key: "password", value: "eryan", diabled: false}, | |
{key: "csrf", value: csrf_token, diabled: false} | |
] | |
} | |
} | |
pm.sendRequest(loginRequest, function(err, res) { | |
var playSession = res.headers.find(h => h.key === "Set-Cookie" && h.value.includes("PLAY_SESSION")); | |
var kv = playSession.value.split("="); | |
console.log(kv); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment