Skip to content

Fetch fails on some https in android 4 #23151

Description

@seriiix

Environment

React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5 CPU 760 @ 2.80GHz
Memory: 2.19 GB / 7.99 GB
Binaries:
Yarn: 1.10.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5014246

Description

Some https URLs request fails on android 4 with no error while it's working on other androids (I've tested on some phones and it fails on 4.4.2 while successful on 5.0.2, 6.0.1, 9)

Reproducible Demo

Create a project and paste the following code into your App.js. Make sure you are running on a device with android 4.4.2. It seems working on android 5+.

import React, {Component} from 'react';
import {Text, View} from 'react-native';

export default class App extends Component {

    componentDidMount() {
        /* this request fails on android 4 while its working on android 5+*/
        fetch('https://jsonplaceholder.typicode.com/posts/1')
            .then(resp => resp.json())
            .then(json => alert(`fail -> ${JSON.stringify(json)}`))
            .catch(err => {
                console.log(err)
            })


        /* this one is successful even on android 4 */
        fetch('https://www.json-generator.com/api/json/get/clfvuKZzOq?indent=2')
            .then(resp => resp.json())
            .then(json => alert(`success -> ${JSON.stringify(json)}`))
    }

    render() {
        return (
            <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
                <Text>https error on android 4</Text>
            </View>
        );
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions