react-native-fetch-polyfill icon indicating copy to clipboard operation
react-native-fetch-polyfill copied to clipboard

Response data incorrect.

Open dreamdev21 opened this issue 6 years ago • 3 comments

I am using this one. Seems good work to increase request timeout. 👍 When I am using React Native fetch, my response like this:

{ type: 'default',
  status: 200,
  ok: true,
  statusText: 200,
  headers: 
   { map: 
      { expires: '0',
        date: 'Fri, 18 Jan 2019 16:58:02 GMT',
        'cache-control': 'no-cache, no-store, must-revalidate',
        etag: 'W/"da-6bFyDrImvMLQzmRrsCZZfgxtxGU"',
        pragma: 'no-cache',
        'content-type': 'text/html; charset=utf-8',
        'content-length': '218',
        'x-powered-by': 'Express',
        connection: 'close' } },
  url: '',
  _bodyInit: '{"message":"SUCCESS","name":"Webm successfully created.","webm":"url"}',
  _bodyText: '{"message":"SUCCESS","name":"Webm successfully created.","webm":"url"}' }

But using this package, response like this:

{ type: 'default',
  status: 200,
  ok: true,
  statusText: 200,
  headers: 
   { map: 
      { expires: '0',
        date: 'Fri, 18 Jan 2019 17:01:36 GMT',
        'cache-control': 'no-cache, no-store, must-revalidate',
        etag: 'W/"da-A1q0qbpER+GrId+SH3CDzv53AYE"',
        pragma: 'no-cache',
        'content-type': 'text/html; charset=utf-8',
        'content-length': '218',
        'x-powered-by': 'Express',
        connection: 'close' } },
  url: '',
  _bodyInit: 
   { listeners: {},
     isRNFetchBlobPolyfill: true,
     multipartBoundary: null,
     _ref: '/Users/webbusiness/Library/Developer/CoreSimulator/Devices/7337DDEB-2116-4BFA-AFE2-CA66FF3ABD12/data/Containers/Data/Application/A98729DE-64C1-418F-A2F1-68BEF8D67050/Documents/RNFetchBlob-blobs/blob-3ejkhkazbpv55cxl5je8dl',
     _blobCreated: true,
     _closed: false,
     cacheName: 'blob-3ejkhkazbpv55cxl5je8dl',
     type: 'text/plain',
     size: 218 },
  _bodyBlob: 
   { listeners: {},
     isRNFetchBlobPolyfill: true,
     multipartBoundary: null,
     _ref: '/Users/webbusiness/Library/Developer/CoreSimulator/Devices/7337DDEB-2116-4BFA-AFE2-CA66FF3ABD12/data/Containers/Data/Application/A98729DE-64C1-418F-A2F1-68BEF8D67050/Documents/RNFetchBlob-blobs/blob-3ejkhkazbpv55cxl5je8dl',
     _blobCreated: true,
     _closed: false,
     cacheName: 'blob-3ejkhkazbpv55cxl5je8dl',
     type: 'text/plain',
     size: 218 } }

Not sure why is different?

My dev info:

React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: (4) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
      Memory: 420.38 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.13.0 - /usr/local/bin/node
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
      Android SDK:
        API Levels: 23, 25, 26, 27, 28
        Build Tools: 26.0.3, 27.0.3, 28.0.3
        System Images: android-26 | Google APIs Intel x86 Atom_64, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: ^16.0.0 => 16.6.0
      react-native: ^0.57.8 => 0.57.8
    npmGlobalPackages:
      eslint-plugin-react-native: 3.5.0
      react-native-cli: 2.0.1

dreamdev21 avatar Jan 18 '19 17:01 dreamdev21

I have the same problem.

jan-happy avatar Feb 01 '19 14:02 jan-happy

I am using axios instead of this one.

dreamdev21 avatar Feb 13 '19 04:02 dreamdev21

You have to call the json() function on your response. return fetch(request) .then((response) => {response.json()}) .then((responseJSON) => { //responseJSON will contain your response }) .catch(error => { return error; });

OroszD avatar Jun 30 '19 21:06 OroszD