如何在Vue Typescript中的异步/等待中处理错误

时间:2018-08-27 17:09:29

标签: javascript typescript vue.js async-await

代码段是

    async getInfo(): Promise<any>{
    let response;
    try{
        response = await Axios.get('api/***')
        //response.json()  
                        //what is json here?
                        //Error here is "[ts] Property 'json' does not exist on type 'AxiosResponse<any>'."      
    }catch(err){
        response = err;
        console.log(err)
    }
    return response;
}

,在这里 err 不会打印为json,我如何将其转换为json?它显示像这样 Error: Request failed with status code 403

0 个答案:

没有答案