我有一个axios调用,用于从数据集中获取UPC。如果成功,我会做一些事情,如果找不到,请再次致电axios以进行POST。
这就是我现在所拥有的,但是当尝试运行get时出现错误(404)时,我会收到422错误。
axios.get('http://localhost:3000/api/products/findOne', {
"params": {
"filter": {
"where": {
"upc": product.upc
}
}
}
}).then(response => {
// UPC Found
}).catch(function(error) {
// UPC Not found
// Post UPC
axios.post('http://localhost:3000/api/products', {
//axios stuff here
}).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
});
我根本不相信自己在正确执行此操作...输入?