user9883888
user9883888

Reputation: 419

How to access callback through function call

dt.status == 401  || dt.status == 403 ? this._getRefreshToken(()=>{
        console.log("hello");
        localStorage.setItem('auth_token', data.data.auth_token);
       }) : null



export function _getRefreshToken(data, callback){
refreshapi._callAPI( actualurl, 'GET', data, (type, dt) => {
    if(type == 'success'){

        callback(dt);

    }
    else{

    }

});

}

when i call _getRefreshToken in that i cannot able to print console, May i know why it is not coming may be the callback the way i do was wrong?

Upvotes: 0

Views: 41

Answers (1)

Puneet Bhandari
Puneet Bhandari

Reputation: 356

`export function _getRefreshToken(data, callback){`

as per definition callback is second argument but while calling method you are passing callback in first argument. Try with below code

`dt.status == 401  || dt.status == 403 ? this._getRefreshToken(null, ()=>{
    console.log("hello");
    localStorage.setItem('auth_token', data.data.auth_token);
   }) : null

`

Upvotes: 1

Related Questions