paw-app

How to evaluate the URL Parameter value in JS Script in paw


I need to create a sign method in JS Parameter. I use some variables like Environment Variable or the Secure Variable in some parameter, and in the sign parameter I need to get the evaluated value of them, but I got undefined. Is there a way to get the evaluated parameter's value?


Solution

  • Here's a way to get a specific URL parameter (evaluated as a string):

    var value = request.getUrlParameterByName('myParam'); // string
    

    If you'd like to get a DynamicString instead, you may use:

    var value = request.getUrlParameterByName('myParam', true); // DynamicString
    return value.getEvaluatedString(); // string
    

    You may also get all URL parameters as a JavaScript object (key-values):

    var params = request.getUrlParameters(); // object
    return params['myParam']; // string
    

    You can get all URL parameters as a JavaScript object where values are DynamicString objects:

    var params = request.getUrlParameters(true); // object
    var value = value['myParam']; // DynamicString
    return value.getEvaluatedString(); // string
    

    I hope it helps!