gpt4 book ai didi

node.js - flutter 如何在http.get请求中传递变量

转载 作者:行者123 更新时间:2023-12-03 03:54:55 24 4
gpt4 key购买 nike

我找到的有关http.get请求抖动的所有文档都从数据库中获取所有数据,我只需要特定的数据,这就是为什么我在本例中的方法中必须将变量传递给服务器的原因?

Future<List<Phone>> getData() async {
String a="bonjour
http.Response response = await http.get(
Uri.encodeFull("http://192.168.43.24:27017/api/posts/gettdata"),
headers: {"Accept": "application/json"});
print(response.body);
List phonee = json.decode(response.body);
return phonee.map((phone) => new Phone.fromJson(phone)).toList();
}
将读取我的请求的服务器将是节点js服务器,我想知道如何找到我传递的参数。
router.get('/gettdatae', (req, res, next) => {
Post.find({imei: {name}}=)
.then((posts) => {
res.json(posts);
console.log(posts);
console.log("ok" + JSON.stringify(req.body) + req.body.imei);
})
.catch(err => console.log(err))
});

最佳答案

试试这个

  Future<List<Phone>> getData() async {
String a="bonjour";
http.Response response = await http.get(
Uri.encodeFull("http://192.168.43.24:27017/api/posts/gettdata?a="+a),
headers: {"Accept": "application/json"});
print(response.body);
List phonee = json.decode(response.body);
return phonee.map((phone) => new Phone.fromJson(phone)).toList();
}

关于node.js - flutter 如何在http.get请求中传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61727236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com