0

The JSON response works as expected

axios.get('https://rallycoding.herokuapp.com/api/music_albums')
      .then(response => console.log(response))

Not able to get response may be because it's XML?

axios.get('http://thefederalistpapers.org/feed')
      .then(response => console.log(response))

Does axios work to fetch XML feed?

Here is the error I am getting:

Possible Unhandled Promise Rejection (id: 0):
Error: Network Error

Basically what I am trying to do is, get the XML from HTTP request and I am not sure how to convert it to JSON

I even tried this react-native-xml2js but did not help because it doesn't support async, not sure.

async (default false): Should the callbacks be async? This might be an incompatible change if your code depends on sync execution of callbacks. Future versions of xml2js might change this default, so the recommendation is to not depend on sync execution anyway. Added in 0.2.6.

Syed
  • 15,657
  • 13
  • 120
  • 154

2 Answers2

2

ios-app-transport-security-and-loading-http-resources

this is known issue in react native iOS it dose not allow http protocol only https unless you made an exception in info.plist

https://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9/30732693#30732693

Mohamed Khalil
  • 3,036
  • 1
  • 20
  • 26
-1

This should work

axios.get('linkgoeshere', { headers: { 'Accept': 'application/json' }})
  .then(response => console.log(response));

Dont know exactly but try it I guess.

Drk Design
  • 11
  • 1