mercredi 18 septembre 2019

Accessing db is creating issues

I am trying to access various elements of a brewery. Everything works except the link and I am not sure what we are doing wrong here.

The only other thing I can think of is that the brewery db hasn't made the web link available even though it shows an a attribute. Attaching the code.

var queryURL = "https://api.openbrewerydb.org/breweries?by_city=" + city; $.ajax({ url: queryURL, method: "GET" }).then(function(response){ console.log(response); $("#brew-list").empty();

    for (var i = 0; i < response.length; i++) {
    var breweryName = $("<h1>").text(response[i].name);
    var website_URL = $("<a>").attr("href", response[i].website_url).appendTo(breweryName);
    var streetAddress = $("<h2>").text("Address: " + response[i].street);
    var city = $("<h1>").text("City: " + response[i].city);
    var phoneNum = $("<h2>").text("Phone Number: " + response[i].phone);


$("#brew-list").append(breweryName, website_URL, streetAddress, phoneNum, city);       

    }

});

Result so far is showing everything as expected besides the website url




Aucun commentaire:

Enregistrer un commentaire