【发布时间】:2021-05-10 07:46:00
【问题描述】:
我正在关注这个 Git:https://github.com/samarthagarwal/woocommerce_dart。 我正在访问 Woocommerce,但我没有从中获取数据。 这是我用来访问 Woocommerce 并尝试在 Flutter 程序中显示数据的部分代码。 希望有人能帮帮我!!!
WooCommerceAPI wooCommerceAPI = WooCommerceAPI(
url: "http://website.com/",
consumerKey: "ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
consumerSecret: "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
List<Technician> techies = [];
// Get data using the "orders" endpoint
var data = await wooCommerceAPI.getAsync("orders");
var jsonData = json.decode(data.body);
for (var u in jsonData) {
Technician myTechy = Technician(u["id"].toString(), u["status"].toString(), u["first_name"], u["last_name"]);
techies.add(myTechy);
}
return techies;
这是课程
class Technician {
final String id;
final String status;
final String first_name;
final String last_name;
// String status;
//int rating;
//String occupation;
Technician(this.id, this.status, this.first_name, this.last_name);
}
【问题讨论】:
-
我在这里遇到了同样的问题
标签: api flutter dart woocommerce woocommerce-rest-api