Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function submitOrder(ord: TOrder, opts: any) {
let endpoint, matcherUrl: string
if ( typeof opts === 'string' ){
matcherUrl = opts
endpoint = 'matcher/orderbook'
}else {
matcherUrl = opts.matcherUrl
endpoint = opts.market ? 'matcher/orderbook/market' : 'matcher/orderbook'
}
return axios.post(endpoint, json.stringifyOrder(ord), {
baseURL: matcherUrl,
headers: { 'content-type': 'application/json' },
})
.then(x => x.data)
.catch(e => Promise.reject(e.response && e.response.status === 400 ? new Error(e.response.data.message) : e))
}