Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

rest - 邮递员返回成功,但浏览器不成功(Postman returns success, but browser don't)

I have a form which related on v-model .

(我有一个与v-model有关的表格。)

So, it is default login page.

(因此,这是默认的登录页面。)

When I try to log in I got unautorized 401, but in Postman I got the token with same credentials.

(当我尝试登录时,我得到了未指定的401,但在邮递员中,我获得了具有相同凭据的令牌。)

export default {
    data() {
        return {
            email: '',
            password: '',
            output: ''
        };
    },
    methods: {
        login() {
            axios.post('api/login', {
                email: this.email,
                password: this.password },
                { headers: {
                        'Content-type': 'application/x-www-form-urlencoded',
                    }
                }).then(response => {
                    this.output = response.data;
            });
        }
    }
}
  ask by Danabek Duisekov translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This worked

(这工作)

axios.post('api/login/',
    {
        email: this.email,
        password: this.password
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...