For the first time, the front and back ends are separated with vue, and the POST request cannot receive data.

now you are doing the function of creating a new account

clipboard.png

post:


clipboard.png

I"ve been debugging all afternoon, but I still don"t know what the problem is. Cry ~


axios needs to add its own configuration using post request

use qs as a class library

import qs from 'qs';
axios.interceptors.request.use( (config) => {
    if (config.method=="post"){
        config.data = qs.stringify(config.data);
        config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
    }
    return config;
},  (error) => {
    return Promise.reject(error);
});

write an api.js, creation interface, such as export const addUser = params = > {return axios.post ( ${base} / _ / api/v1/user , params). Then (res = > res.data);
then import it with import on the page, and then use ~


the backend requires you to put the parameters into url , and your post data is put into body, of course. You can do this by configuring post's config .


is there another status parameter?


axios.post('/account/add',{
    headers: {
        Authorization : getCookie('token')
    },
    params:{
        name:this.name,
        email:this.email,
        password:this.password,
        status:1,
        roleId:this.role  
    }
})

am I right to change to this?


what management interface does the back end of your company use?

Menu