- HttpClient for JavaScript targets implemented as sugar on top of fusion/js/jsxmlhttprequest
Example: cmd: -r:off
import src/nodejs/jshttpclient import fusion/js/jsxmlhttprequest let client = newJsHttpClient() const data = """{"key": "value"}""" echo client.getContent("http://nim-lang.org") echo client.deleteContent("http://httpbin.org/delete") echo client.postContent("http://httpbin.org/post", data) echo client.putContent("http://httpbin.org/put", data) echo client.patchContent("http://httpbin.org/patch", data)
Types
JsHttpClient = ref object of XMLHttpRequest
Procs
proc deleteContent(self: JsHttpClient; url: string or cstring): cstring
proc getContent(self: JsHttpClient; url: string or cstring): cstring
proc head(self: JsHttpClient; url: string or cstring): cstring
func newJsHttpClient(): JsHttpClient {....raises: [], tags: [].}
proc patchContent(self: JsHttpClient; url: string or cstring; body: string or cstring = ""): cstring
proc postContent(self: JsHttpClient; url: string or cstring; body: string or cstring = ""): cstring
proc putContent(self: JsHttpClient; url: string or cstring; body: string or cstring = ""): cstring