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人点赞



  • 2018-01-26 01:05:22

    Android在thread中Toast不能显示问题解决

    一般如果不是在主线程中又开启了新线程的话,一般都会碰到这个问题。 原因是在创建新线程的时候默认情况下不会去创建新的MessageQueue。