Vue-cli axios post request submission data cannot be received

the following figure shows the register method. Send the post request to submit data through axios, and print out the submission result

.

network

cannot receive the input data. What happens? Solve

Mar.23,2021

there is no guarantee that there will be a return value if there is a requested value.
look at the content returned by the request. Maybe the interface just doesn't return anything?!


are you sure that the interface you requested has a return value for you?
your request value is available. But the return value

clipboard.png

such as this


1, your network screenshot is request payload, and you print response; so you have to take a screenshot of what the response of network is.
2, if your response also returns results, see if your this.$emit ('has-register', res.data) action affects res.data.


are you sure there is value in your res.data.data?


1. Because jQuery and axios do not handle data the same way in post requests. The default data of jQuery is in Form format, while axios is the isomorphic payload format of the front and back end. This difference results in different ways for the backend to obtain the data requested by post.
2.

axios({
    url: '/api',
    data:data,
    method: 'POST',
    transformRequest:[function(data){
        return qs.stringify(data)
    }]
}).then(...)

check whether the response in network returns a value


with an extra data

Menu