Get api values with javascript

Hi!
I try to get some values from an api.
The api is https://opendata-download-metfcst.smhi.se/api/category/fwif1g/version/1/daily/geotype/point/lon/15.18/lat/60.13/data.json.

I want for example the value for fwiindex to put on my homepage.
Can I use something similar like

type or paste code here

var queryURL = "//api.luftdaten.info/v1/sensor/13481/";
$.getJSON(queryURL, function(data) {
  var result = data[0].sensordatavalues
  console.log(result);
  var value = result[0].value
  $('#output').append('The value is ' + value);
})

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

If you use the URL it redirects to instead it should work with the code you have.

https://data.sensor.community/airrohr/v1/sensor/13481/

Yes, but I want to have the fwiindex from the api https://opendata-download-metfcst.smhi.se/api/category/fwif1g/version/1/daily/geotype/point/lon/15.18/lat/60.13/data.json

The other code was just an example. I am not really sure how to code to get the value.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.