From f3010cbfb2420fa2e9f5c76c8980fc670df3b0ee Mon Sep 17 00:00:00 2001 From: Louis Schmieder Date: Tue, 30 Jun 2020 14:36:11 +0200 Subject: [PATCH] http: add post function with json as payload (#5580) --- vlib/net/http/http.v | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vlib/net/http/http.v b/vlib/net/http/http.v index d05ce06cff..523e2d9841 100644 --- a/vlib/net/http/http.v +++ b/vlib/net/http/http.v @@ -75,6 +75,15 @@ pub fn post(url, data string) ?Response { }) } +pub fn post_json(url, data string) ?Response { + return fetch_with_method('POST', url, { + data: data + headers: { + 'Content-Type': 'application/json' + } + }) +} + pub fn post_form(url string, data map[string]string) ?Response { return fetch_with_method('POST', url, { headers: {