[Vuejs]-Why do I get this undefined property error message in my promise?

0👍

Try res.data.post_title instead of res.post_title

...
.then((res) => {
  this.title = res.data.post_title
  this.content = res.data.post_content
})
...

Axios return an object containing the following information

{
  data: {},        // the response that was provided by the server
  status: 200,     // the HTTP status code from the server response
  statusText: 'OK',// the HTTP status message from the server response
  headers: {},     // the headers that the server responded with
  config: {},      // the config that was provided to `axios` for the request
  request: {}      // the request that generated this response
}

If you steal get the same error, then it’s probably a server side mal-formatted data, try to console.log the response and see if there any problem serve side.

...
.then((response) => {
    console.log(response.data);
    console.log(response.status);
    console.log(response.statusText);
    console.log(response.headers);
    console.log(response.config);
  });
...

Leave a comment