Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise( ( resolve, reject ) => {
handler( params, ( error, body ) => {
if ( error ) {
reject( error );
} else {
resolve( {
data: camelizeKeys( body ),
requestParams: params,
requestToken: token,
} );
}
} );
} );
}
export default function( params, callback ) {
return xhr( params, function( error, response, headers ) {
if ( error && error.name === 'InvalidTokenError' ) {
debug( 'Invalid token error detected, authorisation probably revoked - logging out' );
require( 'lib/user/utils' ).logout();
}
callback( error, response, headers );
} );
}