1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/examples/fetch.v

13 lines
227 B
V
Raw Permalink Normal View History

2020-04-28 14:57:48 +03:00
import time
import net.http
fn main() {
2021-02-23 20:43:44 +03:00
resp := http.get('https://vlang.io/utc_now') or {
eprintln('Failed to fetch data from the server. Error: ${err}')
2021-02-23 20:43:44 +03:00
return
}
2020-04-28 14:57:48 +03:00
t := time.unix(resp.body.int())
2021-02-23 20:43:44 +03:00
println(t.format())
2020-04-28 14:57:48 +03:00
}