How to set the value received from the response to .js or json file

655 views Asked by At

I am using the karate api framework to automate web services. Currently, I am facing problem to set the response value back to the .js or JSON file which I receive from the cucumber feature file.

My response:{"authorizationtoken" : "58102a8c9e074d578edae8f3d5e96001'}

How can I save this to .js or JSON file to reuse them in other scripts [feature files] ?

Thanks in advance.

1

There are 1 answers

1
brk On BEST ANSWER

You cannot save the value to a .js or JSON file provided you don't want to write the value to a json file

You can assign the value to a variable , let say using a namespacing technique to avoid collision

var nameSpaceObject = {
    authKey : "",
    someOtherFunctionIfNecessary :function(){}

};

Then you can call this name space & assign value to it

var response =  {"authorizationtoken" : "58102a8c9e074d578edae8f3d5e96001' }
  nameSpaceObject.authKey = response.authorizationtoken;