reactjs - 使用 POST 请求将多个/所有数据从 API 传递到另一个 API
问题描述
我正在尝试将所有记录传递到我在单个 POST 请求中从另一个表中获取的表中,但我觉得我的代码正试图将整个记录作为一个大数据传递。
const [myCart, setMyCart] = useState([])
useEffect(() => {
axios
.get("https://localhost:3000/api/cart/")
.then((res) => {
setMyCart(res.data)
console.log(res.data)
})
}, []);
const submitToShip = () => {
axios
.post("https://localhost:3000/api/ship/", myCart)
.then((res) => {
console.log(res.data)
})
}
<button onClick={submitToShip}>Submit</button>
它返回一个错误400
,两个表也具有相同的结构
解决方案
推荐阅读
- typescript - 如何到同一个站点 没有或不是 seame 站点 url cookie chrome http 连接
- docusignapi - 将数据注入 Docusign 模板以创建文档并捕获签名
- java - 通知观察者事件 null 时失败 - 尝试在事务失败时触发事件时
- ruby-on-rails - 是否可以通过 Google Docs Api 为每个页面添加不同的页眉和页脚?
- mongodb - MongoDB - 如何用长度查询没有任何空格的字符串(省略带空格的字符串)
- reactjs - 在子类中使用时,props 在 React js 中未定义
- reporting-services - 所有年份的 DAX 总和,但不是当前年份
- javascript - 高图表 React Native 不适合我
- javascript - 隐藏子组件Vue中的主div
- python - 使用 xlsxwriter 更改行背景