Android Capacitor app throws network error only set headers

Capacitor based Android application created by Quasar and VueJs. Tested With Axios and Fetch API. … Read more Android Capacitor app throws network error only set headers

Capacitor based Android application created by Quasar and VueJs.
Tested With Axios and Fetch API. Run out at Emulator and Real device.
But throws network error at all.
Same code works as web application.

As a result of my different workarounds , it occurs only set headers.
Please assist me through the solution.

Following method(allOrders) requires API_KEY on headers. Never worked on android but works as web application

await api.get(
   'https://api.binance.com/api/v3/allOrders?otherparams..',
  {headers : {'X-MBX-APIKEY': API_KEY }}  
).then(res => {
  alert("allOrders : " + JSON.stringify(res.data))
}).catch(err => {
  alert("allOrders ERROR:" + JSON.stringify(err))
})

Following code (Not required API_KEY on headers) works on android , but set a dummy headers it fails also.

It works

 await api.get(
 'https://api.binance.com/api/v3/exchangeInfo?otherparams..'
).then(res => {
  alert("DATA : " + JSON.stringify(res.data))
}).catch(err => {
  alert(JSON.stringify(err))
})

Throws network error

    await api.get(
 'https://api.binance.com/api/v3/exchangeInfo?otherparams..',
  {headers : {'DUMMY_KEY': 'Blahblah' }}  
).then(res => {
  alert("DATA : " + JSON.stringify(res.data))
}).catch(err => {
  alert(JSON.stringify(err))
})

Source: Vue – Stack Overflow



Leave a Reply

Your email address will not be published. Required fields are marked *