Я пытаюсь выполнить простой API, используя выборку в Android (ReactNative), хотя я новичок, после долгих поисков в Google я наконец помещаю его здесь. Я получаю сообщение об ошибке при выполнении моего кода. Мой вопрос заключается в том, что не так в коде, пожалуйста, подскажите мне.
TypeError: Cannot read property 'fetch' of null, js engine: hermes
Исходный код:
import React from "react";
import { StatusBar } from "expo-status-bar";
import { Button, StyleSheet, Text, View } from "react-native";
import { fetch } from "react-native-ssl-pinning";
export default function App() {
const fetchUserData = () => {
console.log("onClick Fetch data-------------->");
fetch("https://jsonplaceholder.typicode.com/posts/1", {
method: "GET",
timeoutInterval: 10000,
sslPinning: {
certs: ["mycert"],
},
})
.then((response) => {
console.log("in Response-------------->", response.data);
console.log(JSON.stringify(response.bodyString, null, "\t"));
})
.catch((error: any) => {
console.log("ERROR-------------->", error.header);
console.log(`error: ${error}`);
});
};
return (
This is a Testing app for network error
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
marginTop: "auto",
},
});
Подробнее здесь: https://stackoverflow.com/questions/787 ... -js-engine
ReactNative Android TypeError: невозможно прочитать свойство «fetch» со значением null, движок js: hermes ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение