Skip to content

Commit 36cc8a5

Browse files
committed
replace optional
1 parent 31a1b18 commit 36cc8a5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/http-client.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,12 @@ const aggTrades = (pubCall, payload, endpoint = '/api/v3/aggTrades') =>
326326
}),
327327
)
328328

329-
// Convert the array to string to prevent unacceptable encoding
330-
const processSymbols = payload => {
331-
if (payload?.symbols) {
332-
payload.symbols = `["${payload.symbols.join('"')}"]`
333-
}
329+
// Convert the array to string to prevent unacceptable encoding
330+
const processSymbols = payload => {
331+
if (payload && payload.hasOwnProperty('symbols')) {
332+
payload.symbols = `["${payload.symbols.join('"')}"]`
334333
}
334+
}
335335

336336
export default opts => {
337337
const endpoints = {
@@ -362,7 +362,7 @@ export default opts => {
362362
kCall('/api/v3/historicalTrades', payload),
363363

364364
dailyStats: payload => pubCall('/api/v3/ticker/24hr', payload),
365-
prices: payload =>
365+
prices: payload =>
366366
pubCall('/api/v3/ticker/price', processSymbols(payload)).then(r =>
367367
(Array.isArray(r) ? r : [r]).reduce((out, cur) => ((out[cur.symbol] = cur.price), out), {}),
368368
),

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ test('[REST] individual price', async t => {
104104
})
105105

106106
test('[REST] multiple prices', async t => {
107-
const prices = await client.prices({ symbols: ["ETHUSDT","ETHBUSD"] })
107+
const prices = await client.prices({ symbols: ['ETHUSDT', 'ETHBUSD'] })
108108
t.truthy(prices)
109109
t.truthy(prices.ETHUSDT)
110110
t.truthy(prices.ETHBUSD)

0 commit comments

Comments
 (0)