diff --git a/examples/fetch.v b/examples/fetch.v new file mode 100644 index 0000000000..7f2b8626e7 --- /dev/null +++ b/examples/fetch.v @@ -0,0 +1,13 @@ +import time +import net.http + +fn main() { + resp := http.get('https://vlang.io/utc_now') or { + println('failed to fetch data from the server') + return + } + + t := time.unix(resp.text.int()) + println(t.format()) +} + diff --git a/vlib/net/http/http.v b/vlib/net/http/http.v index e1951993d7..e9f658b7fd 100644 --- a/vlib/net/http/http.v +++ b/vlib/net/http/http.v @@ -12,7 +12,7 @@ const ( ) pub struct Request { -pub: +pub mut: method string headers map[string]string cookies map[string]string