S Pat
S Pat

Reputation: 409

retrieve JSON response from Frisby POST in another function

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

Upvotes: 1

Views: 360

Answers (1)

DevArti
DevArti

Reputation: 38

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

Upvotes: 0

Related Questions