How to add relative path in open for POST request

My code is as below:

var test = open("../../requestData");

export default function main() {
    let response;
     response1 = commonUrl + "/logout", test + '/Sourcing/logout.json' , { headers: headers}); 

Get error as not able to append the path to the variable. Have to specify the absolute path to in test variable to run the code. Also tried below to open it in post request not able to proceed further as gives error for open.

response1 = commonUrl + "/logout", open(test + '/Sourcing/logout.json') , { headers: headers}); 

any idea how I can define relative paths in op

Hi @dee.adya1,
You cannot open files outside of the init context.

I propose that you just open all the relevant files and have them in global variables as test in your example.

Thanks for replying. Yes will have to do, the only problem was facing was the maintenance of 100 api absolute files paths, might become a bit tedious hence wanted to common path until request data and add separate path later in the request. Anyways, if there is any other solution please let us know thanks :slight_smile:

you can still do

var commonPath = "../../something"
var first = open(commonPath+"/first");
var second = open(commonPath+"/second");

Got it… tried the same way… thanks once again for your prompt response.