axios设置header信息

2020-12-29 15:46:56

注意事项 参数是headers 不是header

以下方法是在vue-cli 中使用,this指vue

    this.axios.post(`${API_HOST}/api/auth/login`, obj, {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    }).then(function(response) {
        const data = response.data;
    }, function(response) {});

    this.axios({
        method: "POST",
        url: `${API_HOST}/api/bind/index`,
        data: obj,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    }).then(function(res) {
        console.log(res);
    });

5人点赞



  • 2023-08-19 18:57:08

    强制杀死nginx进程简单粗暴

    nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory),最简单的办法,杀死nginx进程,重启