Garmaine Staff asked 2 years ago

This is really annoying me. if i use http://my-domain.com its work with out Network request failed, but https://my-domain.com its keep giving me Network request failed error.

i been looking online and still not fix this issue. Please help.

package.json

"dependencies": {
"@expo/vector-icons": "~10.0.6",
"@react-native-community/masked-view": "0.1.6",
"@react-navigation/bottom-tabs": "^5.0.0",
"@react-navigation/native": "^5.0.0",
"@react-navigation/stack": "^5.0.0",
"@react-navigation/web": "~1.0.0-alpha.9",
"expo": "~37.0.3",
"expo-asset": "~8.1.3",
"expo-constants": "~9.0.0",
"expo-font": "~8.1.0",
"expo-web-browser": "~8.1.0",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-gesture-handler": "~1.6.0",
"react-native-iphone-x-helper": "^1.2.1",
"react-native-modalize": "^1.3.7-rc.19",
"react-native-safe-area-context": "0.7.3",
"react-native-screens": "~2.2.0",
"react-native-web": "~0.11.7"

},

Fetch code

const [contents, setContents] = useState([]);

const fetchChannelContent = (slug) => {
    fetch(Http.api+"/channel/"+slug)
        .then((response) => response.json())
        .then((json) => {
            setContents(json.channel.content);
        })
        .catch((error) => {
            console.error(error);
        });
};

useEffect(() => {
    fetchChannelContent(url)
}, []);[![enter image description here][1]][1]

[1]:

Http Class

export default {
api: "https://my-domain.com"

}