API call within API test

Hello all, I have been writing some tests for our API’s.

And problem is we need to call another API with POST method and get TOKEN to make further tests on MAIN API with get requests that needs testing, however with my code both API’s are getting called at same time basically in same function as it is how I wrote it, is it possible to somehow call TOKEN api outside of a function?
Or just to post request once within same script ?

Hi @sillymoomoo,
this is a common use case for the Setup stage where you obtain the token from the Setup function and pass it through the VUs setting the setupData JSON.

Let me know if it helps.

Thanks for response @codebien ! I am experimenting with setup at the moment, but is it possible to use setup method from different file to call it?