如何在节点 js 中使用 woocommerce api 更新订单
How update orders by using woocommerce api in node js
exports.UpdateOrder = (req, res) => {
const data = {
status: "completed"
};
WooCommerce.put("orders/3217", data)
.then((response) => {
res.json(JSON.parse(response.body));
})
.catch((error) => {
console.log(error.response.data);
});
};
获取错误
TypeError: WooCommerce.put(...).then 不是函数
也许尝试使用本例中的 promisified 方法 https://www.npmjs.com/package/woocommerce-api#promified-methods
Promified Methods
Every method can be used in a promified way just adding Async to the method name. Like in:
WooCommerce.getAsync('products').then(function(result) {
return JSON.parse(result.toJSON().body);
});
exports.UpdateOrder = (req, res) => {
const data = {
status: "completed"
};
WooCommerce.put("orders/3217", data)
.then((response) => {
res.json(JSON.parse(response.body));
})
.catch((error) => {
console.log(error.response.data);
});
};
获取错误 TypeError: WooCommerce.put(...).then 不是函数
也许尝试使用本例中的 promisified 方法 https://www.npmjs.com/package/woocommerce-api#promified-methods
Promified Methods Every method can be used in a promified way just adding Async to the method name. Like in:
WooCommerce.getAsync('products').then(function(result) {
return JSON.parse(result.toJSON().body);
});