0
我试图做一个GET请求,它将从mySQL数据库触发SELECT查询。但是,我需要这个请求是动态的,因为要查询的数据取决于用户的输入。以下是我想出基于我如何执行POST请求:mySql/Express GET请求到React Native应用程序中的动态SELECT查询
*的handlePress功能获取在其各自的组分选择
handlePress = (inputId) => {
fetch('http://127.0.0.1:3000/testData', {
"method": "GET",
body: JSON.stringify({
id: inputId
})
})
.then((response) => response.json())
.then((responseData) => {
this.setState({newData: responseData})
})
}
app.get('/testData', function (req, res) {
connection.query('select * from ticket_data where id = ' + req.body.id, function(error, results, fields) {
if(error) {
console.log('Error in GET/query')
} else {
res.send(results);
}
})
})