aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/src/http_client.ts
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2018-02-21 02:55:10 +0800
committerGitHub <noreply@github.com>2018-02-21 02:55:10 +0800
commitf60b00d116e525e5b789684e68b1541cedba1665 (patch)
tree9c8f33bafb1fb2eef5bfcaaefed781ccae6ffba9 /packages/connect/src/http_client.ts
parent76afb6b1163182446a1f3646b4bc89b5dc271738 (diff)
parent3a36e0621f0ad0c77c14a04bdaa85131b57ef0ea (diff)
downloaddexon-sol-tools-f60b00d116e525e5b789684e68b1541cedba1665.tar
dexon-sol-tools-f60b00d116e525e5b789684e68b1541cedba1665.tar.gz
dexon-sol-tools-f60b00d116e525e5b789684e68b1541cedba1665.tar.bz2
dexon-sol-tools-f60b00d116e525e5b789684e68b1541cedba1665.tar.lz
dexon-sol-tools-f60b00d116e525e5b789684e68b1541cedba1665.tar.xz
dexon-sol-tools-f60b00d116e525e5b789684e68b1541cedba1665.tar.zst
dexon-sol-tools-f60b00d116e525e5b789684e68b1541cedba1665.zip
Merge branch 'development' into feature/web3-abi-v2-types
Diffstat (limited to 'packages/connect/src/http_client.ts')
-rw-r--r--packages/connect/src/http_client.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
index 815d42e67..cf0aaef0d 100644
--- a/packages/connect/src/http_client.ts
+++ b/packages/connect/src/http_client.ts
@@ -23,7 +23,7 @@ import { relayerResponseJsonParsers } from './utils/relayer_response_json_parser
const TRAILING_SLASHES_REGEX = /\/+$/;
const DEFAULT_PAGED_REQUEST_OPTS: PagedRequestOpts = {
- page: 0,
+ page: 1,
perPage: 100,
};
/**
@@ -66,7 +66,7 @@ export class HttpClient implements Client {
}
/**
* Retrieve token pair info from the API
- * @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 0, perPage: 100 }
+ * @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting TokenPairsItems that match the request
*/
public async getTokenPairsAsync(requestOpts?: TokenPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]> {
@@ -83,7 +83,7 @@ export class HttpClient implements Client {
}
/**
* Retrieve orders from the API
- * @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 0, perPage: 100 }
+ * @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting SignedOrders that match the request
*/
public async getOrdersAsync(requestOpts?: OrdersRequestOpts & PagedRequestOpts): Promise<SignedOrder[]> {
@@ -112,7 +112,7 @@ export class HttpClient implements Client {
/**
* Retrieve an orderbook from the API
* @param request An OrderbookRequest instance describing the specific orderbook to retrieve
- * @param requestOpts Options specifying page information, defaults to { page: 0, perPage: 100 }
+ * @param requestOpts Options specifying page information, defaults to { page: 1, perPage: 100 }
* @return The resulting OrderbookResponse that matches the request
*/
public async getOrderbookAsync(
@@ -172,13 +172,12 @@ export class HttpClient implements Client {
body: JSON.stringify(payload),
headers,
});
- const json = await response.json();
+ const text = await response.text();
if (!response.ok) {
- const errorString = `${response.status} - ${response.statusText}\n${requestType} ${url}\n${JSON.stringify(
- json,
- )}`;
+ const errorString = `${response.status} - ${response.statusText}\n${requestType} ${url}\n${text}`;
throw Error(errorString);
}
- return json;
+ const result = !_.isEmpty(text) ? JSON.parse(text) : undefined;
+ return result;
}
}