[Vuejs]-Laravel api returns value in postman but returns empty array in Vue js

0👍

Assuming this.$http is Axios and this.passport_number is a string, you’re missing the field / property name for the request payload, ie "passport_number". Also, your Content-type header is incorrect.

Try this instead

this.$http.post("/searchpassport", {
  passport_number: this.passport_number
}, {
  headers: {
    Authorization: `Bearer ${this.token.access_token}`
  }
})

You do not need to supply the Accept or Content-type headers. The defaults will be sufficient.


It’s good practice to use your browser’s developer tools for debugging. The Network tab in particular is great for checking the headers and data sent in your HTTP requests and the responses you get back.

Leave a comment