"react-native: 0.60.4
"react": "16.8.6",
1.react-native init project
2.fetch one request
3.console the response
function request(url, option) {
const newOptions = option
if (newOptions.method === 'POST') {
newOptions.body = JSON.stringify(newOptions.body)
}
return fetch(url, newOptions)
.then(response => {
console.log('newOptions', newOptions)
console.log('response', response)
return response.text()
})
.then(body => {
console.log('body', body)
})
.catch(e => {
console.log('e', e)
})
}
// get request
export async function get(url, params) {
let requrl = stringify(params, { indices: false })
return request(`${baseUrl}${url}?${requrl}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
'content-type': 'application/json'
}
})
}
response={
bodyUsed: true
headers: Headers
map: {content-type: "application/vnd.api+json", content-length: "551"}
__proto__: Object
ok: true
status: 200
statusText: ""
type: "default"
url: "https://chain-api.test.com/question/list?"
_bodyInit: Blob {size: 1177, type: "application/vnd.api+json"}
_bodyText: "[object Blob]"
}
body [object Blob]
Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety?
馃憠 Click here if you want to take another look at the Bug Report issue template.
I'm struggling with the same issue. I believe it's related to: https://github.com/facebook/react-native/issues/25701
add the follow in the entry index.js,then it can work
GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest
global.Blob = null
@guaiguaimao Thanks for your reply to fix this issue and it fixed for me for iOS device but it is not working for Android.
@guaiguaimao this fix causes another problems. I have web-sockets in my application and after that when I try to emmit events with object as parameters socket.emit('someEvent', { param }); it throw an error: "TypeError: Right-hand side of 'instanceof' is not an object"
Most helpful comment
I'm struggling with the same issue. I believe it's related to: https://github.com/facebook/react-native/issues/25701