Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Fetch Replacement evalues to object, not function #190

Closed
rwillemsandroid opened this issue Nov 21, 2016 · 1 comment
Closed

Fetch Replacement evalues to object, not function #190

rwillemsandroid opened this issue Nov 21, 2016 · 1 comment

Comments

@rwillemsandroid
Copy link

RN version: 0.35
RNFetchBlob version: 0.10.0
Platform: Android & iOS

I tried using the fetch replacement functions as documented here:
https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetch-replacement

import RNFetchBlob from 'react-native-fetch-blob';

const Fetch = RNFetchBlob.polyfill.Fetch;
// replace built-in fetch
window.fetch = new Fetch({
    // enable this option so that the response data conversion handled automatically
    auto : true,
    // when receiving response data, the module will match its Content-Type header
    // with strings in this array. If it contains any one of string in this array,
    // the response body will be considered as binary data and the data will stored
    // in file system instead of in memory.
    // By default, it only store response data to file system when Content-Type
    // contains string `application/octet`.
    binaryContentTypes : [
        'image/',
        'video/',
        'audio/',
    ]
});

However, when I do this and use fetch(), I get the following error:

fetch is not a function
TypeError: fetch is not a function

Logging the replacement fetch function yields the following:

console.log("RNfetchblob fetch: " , fetch);

screen shot 2016-11-21 at 12 42 00

The original fetch function looks like this:

screen shot 2016-11-21 at 12 30 35

Any help into solving this issue is greatly appreciated.

@wkh237
Copy link
Owner

wkh237 commented Nov 21, 2016

@rwillemsandroid , thanks for reporting this issue. I think this is an mistake on document, please reference to the test case for proper usage.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants