Last active
July 14, 2022 16:59
-
-
Save kgilpin/17a3ca05b51b9b7dab9d3a4a73718ef8 to your computer and use it in GitHub Desktop.
Rails Sample App 6th Ed Postman Pre-request script
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
| pm.sendRequest(pm.variables.get('baseUrl'), function (err, response) { | |
| const token = /meta\s+name="csrf-token"\s+content="(.*)"/.exec(response.text()); | |
| console.log(`CSRF protection: ${token}`); | |
| if( token) { | |
| pm.globals.set('authenticity_token', token[1]); | |
| } | |
| }) |
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Invoke like this: