{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/1929","labels_url":"https://api.github.com/repos/facebook/react-native/issues/1929/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/1929/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/1929/events","html_url":"https://github.com/facebook/react-native/issues/1929","id":94197609,"number":1929,"title":"[XMLHttpRequest] How to use Fetch API to get excel file data from a link","user":{"login":"bright-sea","id":2636836,"avatar_url":"https://avatars.githubusercontent.com/u/2636836?v=3","gravatar_id":"","url":"https://api.github.com/users/bright-sea","html_url":"https://github.com/bright-sea","followers_url":"https://api.github.com/users/bright-sea/followers","following_url":"https://api.github.com/users/bright-sea/following{/other_user}","gists_url":"https://api.github.com/users/bright-sea/gists{/gist_id}","starred_url":"https://api.github.com/users/bright-sea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bright-sea/subscriptions","organizations_url":"https://api.github.com/users/bright-sea/orgs","repos_url":"https://api.github.com/users/bright-sea/repos","events_url":"https://api.github.com/users/bright-sea/events{/privacy}","received_events_url":"https://api.github.com/users/bright-sea/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/Icebox","name":"Icebox","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-10T02:26:35Z","updated_at":"2016-01-02T02:15:06Z","closed_at":null,"body":"I can use fetch to get csv file data (text) from a link like:\r\n\r\n               fetch(this.state.fileUrl)\r\n                    .then((response) => {\r\n                        console.log(\"response\", response);\r\n                        return response.text();\r\n                    })\r\n\r\nBut if the fileUrl was a link to an excel file, the response.body was null and response.text was empty. \r\n\r\nI tried use XmlHttpRequest directly, like:\r\n\r\n               var request = new XMLHttpRequest();\r\n                \r\n                request.responseType = \"blob\";\r\n                request.onreadystatechange = (e) => {\r\n                    if (request.readyState !== 4) {\r\n                        return;\r\n                    }\r\n                    if (request.status === 200) {\r\n                        console.log('success', request);\r\n                    } else {\r\n                        console.warn('error');\r\n                    }\r\n                };\r\n\r\n                request.onload = function(oEvent) {\r\n                    var blob = request.response;\r\n                    console.log(\"blob\", blob);\r\n                    // ...\r\n                };\r\n                \r\n                request.open('GET', this.state.fileUrl);\r\n                request.send();\r\n\r\nIt was the same. I also tried use superagent library, still the same:\r\n\r\n               agent.get(this.state.fileUrl)\r\n                    .accept('application/vnd.ms-excel')\r\n                    .end(function(err, response) {\r\n\r\n                    console.log(\"agent response\", response);\r\n                });\r\n\r\nIs fetch (and XmlHttpRequest) support in react native only can fetch text data, no binary data. Or I am doing something wrong at here?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/168357444","html_url":"https://github.com/facebook/react-native/issues/1929#issuecomment-168357444","issue_url":"https://api.github.com/repos/facebook/react-native/issues/1929","id":168357444,"user":{"login":"brentvatne","id":90494,"avatar_url":"https://avatars.githubusercontent.com/u/90494?v=3","gravatar_id":"","url":"https://api.github.com/users/brentvatne","html_url":"https://github.com/brentvatne","followers_url":"https://api.github.com/users/brentvatne/followers","following_url":"https://api.github.com/users/brentvatne/following{/other_user}","gists_url":"https://api.github.com/users/brentvatne/gists{/gist_id}","starred_url":"https://api.github.com/users/brentvatne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brentvatne/subscriptions","organizations_url":"https://api.github.com/users/brentvatne/orgs","repos_url":"https://api.github.com/users/brentvatne/repos","events_url":"https://api.github.com/users/brentvatne/events{/privacy}","received_events_url":"https://api.github.com/users/brentvatne/received_events","type":"User","site_admin":false},"created_at":"2016-01-02T02:15:06Z","updated_at":"2016-01-02T02:15:06Z","body":"Hi there! This issue is being closed because it has been inactive for a while.\n\nBut don't worry, it will live on with ProductPains! Check out it's new home: https://productpains.com/post/react-native/xmlhttprequest-how-to-use-fetch-api-to-get-excel-file-data-from-a-link\n"}}