retrieve JSON response from Frisby POST in another function

347 views Asked by At

i got a frisby function

createPOST = function () {
    return frisby.post(url, {
            body: qs.stringify({
                username: data.user,
                password: data.password
            }),
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        })
        .then((resp) => {
            let respJson = resp.json;
            return respJson;
        }, (error) => {
            console.error("Error:: " + error);
            throw error;
        });
} 

and second function

getRespJson = function ()  {
    createToken().then(function (value) {
        console.log("resp::"+value);
    });
}

im trying to retrieve this json response in another function, but not able to using frisby. no log is even displaying

1

There are 1 answers

0
DevArti On

If your data coming in the body(that you are expecting) or anywhere, simply store into other variable and then by nested way you able to use it. if you have multiple nested body then in that situation you also able to use it. I'm using the same with that workaround. or try to use it by storing that into another file.

Thanks