【发布时间】:2018-01-18 10:09:13
【问题描述】:
如何在 react native 中将参数与获取请求一起传递。这可能吗?
【问题讨论】:
标签: react-native parameter-passing fetch
如何在 react native 中将参数与获取请求一起传递。这可能吗?
【问题讨论】:
标签: react-native parameter-passing fetch
fetch('https://mywebsite.com/endpoint/', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
firstParam: 'yourValue',
secondParam: 'yourOtherValue',
}),
});
阅读更多关于Making Request
【讨论】:
id 从我的firstScreen 传递到SecondScreen 并尝试在SecondScreen 中访问它,它工作正常..但是沿着与fetch 请求我可以提供id 吗??
<TouchableOpacity onPress={() =>this.props.navigation.navigate("SecondScreen",{id: user.data.id})}> 和第二个屏幕fetch('https:www.mywebiste.com/' + 'id')..
SecondScreen 中获得id,您必须像fetch('https:www.mywebiste.com/' + this.props.navigation.state.params.id) 一样获得它