can’t figure out why i can’t retrieve data from my api

You are using a promise incorrectly. The correct syntax is .then(result => {}).catch(e => {})

Like this

const cityName = $("#city").val()
$.ajax({url: url})
   .then((data, a, b, c) => {
      console.log("It's working!")
   .catch(error => {
      console.error(error) //not necessarily a "bad request"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top