vue.js axios call api example

时间:2021-06-28 19:29:47   收藏:0   阅读:0


代码样例:

技术图片

 

 

 code:

技术图片
let url = ‘/api/xxx/yyy‘;
            let paramObj = JSON.stringify(
                {
                }
            );
            axios
                .post(url,
                    paramObj,
                    {
                        headers: {
                            ‘Content-Type‘: ‘application/json; charset=utf-8‘
                        }
                    })
                .then(response => {
                    if (response.data.ResponseStatus) {
                        //do success coding...
                    }
                    else {
                        //do fail coding...
                    }
                })
                .catch(error => {
                    console.log(error)
                })
                .finally(() => {
                    //do something...
                })
Source Code

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!