Debian Codegraph @

obvious/weather/forecast.lua

raw symbols SCIP
1 local json = require 'json'
2 local http_request = require 'http.request'
3
4 local function get(api_key, latitude, longitude, units)
5 local body = {}
6 local url = string.format('https://api.darksky.net/forecast/%s/%s,%s?units=%s',
7 api_key,
8 latitude,
9 longitude,
10 units)
11 local headers, stream = assert(http_request.new_from_uri(url):go(10))
12 local body = assert(stream:get_body_as_string())
13
14 return json.decode(body)
15 end
16
17 return { get = get }