Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

bad api request in vuejs with axios?

I have a method to request a movie form an api. i use axios to get my request with an await before the the get and async before the method. i debbuged it, and it is at the const { data: results } = await axios.get(ui.movieName.baseUrl + ui.movieName.urlScoped) line. is my utilisation of async and await is needed? or i dont use promess right way?

async loadMovieName () {
      const { data: movies } = await axios.get(baseUrl + urlMovie0)
      this.movieName = movies.movies[0].name
      }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Have you tried to put your request inside a try catch statement? For me, i never did an axios request without being in a try ctach. Also are you sure about your url is ok and have the right route to the api? Inside movies when you make the axios get, is movies.movies[0] is ok, it look sketchy imo. And last the ting i would think would be if get is the right method for your request.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading