diff options
| author | Florian Dold <florian.dold@gmail.com> | 2016-01-05 01:13:48 +0100 |
|---|---|---|
| committer | Florian Dold <florian.dold@gmail.com> | 2016-01-05 01:13:48 +0100 |
| commit | 1002f33d017661e3b3b7e5746e3cd5e48ce8a4d4 (patch) | |
| tree | f281f97b897f65595af7ca7f52a65433f00531b8 /extension/background/wallet.ts | |
| parent | c9fc0c31efa36ed6095971be693148d774667bb8 (diff) | |
Split http helpers into file.
Diffstat (limited to 'extension/background/wallet.ts')
| -rw-r--r-- | extension/background/wallet.ts | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/extension/background/wallet.ts b/extension/background/wallet.ts index c6152253e..bc0a1a0f0 100644 --- a/extension/background/wallet.ts +++ b/extension/background/wallet.ts @@ -604,57 +604,6 @@ function updateReserve(db: IDBDatabase, } -interface HttpResponse { - status: number; - responseText: string; -} - - -function httpReq(method: string, - url: string|uri.URI, - options?: any): Promise<HttpResponse> { - let urlString: string; - if (url instanceof URI) { - urlString = url.href(); - } else if (typeof url === "string") { - urlString = url; - } - - return new Promise((resolve, reject) => { - let myRequest = new XMLHttpRequest(); - myRequest.open(method, urlString); - if (options && options.req) { - myRequest.send(options.req); - } - myRequest.addEventListener("readystatechange", (e) => { - if (myRequest.readyState == XMLHttpRequest.DONE) { - let resp = { - status: myRequest.status, - responseText: myRequest.responseText - }; - resolve(resp); - } - }); - }); -} - - -function httpGet(url: string|uri.URI) { - return httpReq("get", url); -} - - -function httpPost(url: string|uri.URI, body) { - return httpReq("put", url, {req: JSON.stringify(body)}); -} - - -class RequestException { - constructor(detail) { - - } -} - /** * Update or add mint DB entry by fetching the /keys information. * Optionally link the reserve entry to the new or existing |
