Superagent access interface, how to save the results separately

I want to use superagent to send requests to access multiple interfaces. If I get the token, from the first interface, but there are several other requests that need to use the token, I should store the token in a single variable. Would you like to ask superagent if there are any feasible ways to extract and save the request results

this is the code for the first request:

var request = require("superagent");
function get(){
    return new Promise(function(resolve, reject){
    request
        .post(url)
        .then((res)=>{
            var resToken = JSON.parse(res.text)
            resolve(resToken)
        })
    })
}

the goal now is to take out the resToken separately, because there are several other requests that need to refer to this value, so is there any better way to save it

Mar.05,2021

should be able to be written in promise, with the data returned from the previous one as the next parameter

Menu