import Taro from '@tarojs/taro' ; import { IResError } from 'src/interfaces/common' ; import { request } from '@tarojs/taro' ; param { Response } response returns { Promise } export default function responseHandler ( response ) { return new Promise ( ( resolve , reject ) => { if ( response . statusCode !== 200 ) { return reject ( { code : response . statusCode , data : response . data } ) ; } if ( response . data . error_code === 401 ) { Taro . removeStorageSync ( 'access_token' ) ; Taro . navigateTo ( { url : '/pages/account/login/index' } ) ; return reject ( { code : response . data . error_code , message : response . data . error_msg } ) ; } else if ( response . data . error_code ) { return reject ( { code : response . data . error_code , message : response . data . error_msg } ) ; } resolve ( response . data . response_data ) ; } ) ; }