Skip to content

Instantly share code, notes, and snippets.

@mittsh
Last active September 2, 2020 12:13
Show Gist options
  • Save mittsh/b50f2d8190d3434e7aad5f02db7a6c27 to your computer and use it in GitHub Desktop.
Save mittsh/b50f2d8190d3434e7aad5f02db7a6c27 to your computer and use it in GitHub Desktop.
Access the (constant) header from a request in Paw
// context docs: https://paw.cloud/docs/reference/ExtensionContext
// request docs: https://paw.cloud/docs/reference/Request
// http exchange docs: https://paw.cloud/docs/reference/HTTPExchange
function evaluate(context){
// get the request we're interested in
var request = context.getRequestByName('Request')
// get the last "HTTP Exchange" (request sending)
var lastExchange = request.getLastExchange()
// get the UUID from the header
var uuid = lastExchange.getRequestHeaderByName('X-UUID')
// return and use that UUID
// it will stay constant until the initial request "Request" is being sent again
return uuid;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment