Relative Content

Tag Archive for javascriptjsonapi

No Return on API JSON, Want to Display a Text

I am using an API from Aeris Weather Alerts and when there is no alerts for the area, the response is blank (“response”: []). Using the code below, is there a code I can use when the response is blank to have a default text that reads “No Weather Alerts”?

Trouble in API Calling

// Initialize and add the map function initMap() { // Map options var mapOptions = { center: { lat: 28.618846, lng: 77.284942 }, zoom: 12 }; // Create a map object var map = new google.maps.Map(document.getElementById(“map”), mapOptions); // Fetch the coordinates and addresses from the API fetch(“http://inventorysoftware.co.in/api/Users/FetchtrackingbyDate”) .then(response => response.json()) .then(data => { const locations […]