So, doing an API call from Client over the Server gives me a different type of results.
Instead of receiving an error: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
I get this error: Error: Request failed with status code 401
Why is that, how could I send my own error message instead of autogenerated by express ?
// Server.js /some/endpoint
const apikey = 'wrongkey'
const apisec = 'wrongsec'
try {
const balance = await exchange.client.fetchBalance()
} catch (error) {
console.log(error)
// AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
return error
}
// Client.js
try {
request = await api.get(`/api/v1/exchanges/balance`, { params: { uid } })
return request.data
} catch (error) {
console.log(error)
// Error: Request failed with status code 401 <-- WHY THIS RESPONSE
}