1 | import { FetchHttp, Http as coreHttp } from '@akala/core';
|
2 | import * as xml2js from 'xml2js'
|
3 |
|
4 | FetchHttp.prototype['getXML'] = function (this: FetchHttp, url: string)
|
5 | {
|
6 | return this.call({ url: url, method: 'get' }).then(r => r.text().then(text =>
|
7 | {
|
8 | return new Promise((resolve, reject) =>
|
9 | {
|
10 | xml2js.parseString(text, { async: true }, function (err, result)
|
11 | {
|
12 | if (err)
|
13 | reject(err);
|
14 | else
|
15 | resolve(result);
|
16 | });
|
17 | })
|
18 | }))
|
19 | }
|
20 |
|
21 | export interface Http extends coreHttp
|
22 | {
|
23 | getXML<T=any>(url: string): PromiseLike<T>
|
24 | } |
\ | No newline at end of file |