Skip to content

Fetch response.text() gives responseData =[Object Blob] #26015

@guaiguaimao

Description

@guaiguaimao

fetch response.text() gives responseData=[Object Blob]

"react-native: 0.60.4
"react": "16.8.6",

Steps To Reproduce

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'
      }
    })
  }

console result

    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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugRan CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.🌐NetworkingRelated to a networking API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions