【发布时间】:2020-04-02 12:41:42
【问题描述】:
我想从 localhost:4547 检索数据
所以,我有一个名为 loadText 的函数,假设在这段代码中这样做:
import React, { useState } from 'react'
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native'
import { TextInput } from 'react-native-gesture-handler'
import { response } from 'express'
export default function Home(props) {
const { navigation } = props
return (
<View>
<Text>Login Screen</Text>
<Text>{loadText}</Text>
</View>
)
function loadText(){
fetch('http://192.168.1.14:4547/')
.then((response) => response.json())
.then((responseJson) => {
return (
alert(JSON.stringfy(responseJson))
);
})
.catch((error) => {
alert(JSON.stringfy(error));
});
}
}
【问题讨论】:
-
你能尝试通过你的项目搜索
111吗?看起来你的 package.json 中有111 -
@OleksandrPaiziak 我的 package.json 中没有 111 的任何内容。我编辑了我的问题,因此如果需要,您可以查看我的 package.json
-
正如答案所暗示的,只需关闭捆绑器并重新启动它
-
alert(JSON.stringfy那是不行的
标签: javascript reactjs react-native npm expo