Node.js Restful API请求
我正在创建一个应用程序,应该显示视频游戏的封面和一些相关信息。我使用的API称为IGDB,它提供了我需要的所有信息。然而,视频游戏的名称和封面艺术需要单独的要求 这是我现在掌握的代码:Node.js Restful API请求,node.js,react-native,api,Node.js,React Native,Api,我正在创建一个应用程序,应该显示视频游戏的封面和一些相关信息。我使用的API称为IGDB,它提供了我需要的所有信息。然而,视频游戏的名称和封面艺术需要单独的要求 这是我现在掌握的代码: async function fetchGames() { try { const {data} = await axios.get('http://10.0.2.2:9000/coverInfo') setGames(data) } catch (error
async function fetchGames() {
try {
const {data} = await axios.get('http://10.0.2.2:9000/coverInfo')
setGames(data)
} catch (error) {
console.log("error", error)
Alert.alert('Error getting users', '', [{text: 'Retry', onPress: () => fetchGames()}])
}
}
这是获取以下类别信息的初始api请求:
然而,在那个请求中,游戏字段只是为游戏生成一个参考ID,我不知道如何使用它。我相信我需要的信息在这个api调用下:
我能够成功地获得图像显示,但我无法访问实际的游戏名称和其他相关信息
这是我必须在主屏幕上显示封面的代码:
export default function SwipeableImage({ game, willLike, willPass }) {
//console.log(game)
return (
<View>
<Image source={{ uri: `https:${game.url.replace('t_thumb', 't_1080p_2x')}` }} style={[styles.photo, { width: 400, height: 640 }]} />
{willLike && (
<View style ={styles.likeBox}>
<Text style= {{...styles.textPrimary, color:'#64EDCC'}}>LIKE</Text>
</View>
)}
{willPass && (
<View style ={styles.passBox}>
<Text style= {{...styles.textPrimary, color:'#F06795'}}>NOPE</Text>
</View>
)}
<View style= {styles.textContainer}>
<View style={styles.textRow}>
<Text style={[styles.textPrimary, styles.textShadow]}>{game.game}</Text>
{/* <Text style={[styles.textSecondary, styles.textShadow]}>{game.dob.age}</Text> */}
</View>
<View style={styles.textRow}>
<FontAwesome name="map-marker" size={20} color ="white"></FontAwesome>
{/* <Text style={[styles.textSecondary, styles.textShadow]}>{game.location.city}</Text> */}
</View>
</View>
</View>
)
}
导出默认函数SwipeableImage({game,willLike,willPass}){
//控制台日志(游戏)
返回(
{willike&&(
喜欢
)}
{willPass&&(
不
)}
{游戏,游戏}
{/*{game.dob.age}*/}
{/*{game.location.city}*/}
)
}
重申一下,如何使用参考ID显示游戏名称并将信息链接在一起