mysql - 从 React JS Axios 调用 API POST 时值变为空
问题描述
我有一个 API TxnController,它接受参数@txnumber、@qnumber、@accountnumber、@amount、@emailaddress)。
使用此示例字符串时
{"txNumber":"1-202042121323","qNumber":65,"accountNumber":"12","amount":"12","emailAddress":""}
我能够使用 POSTMAN 保存它。
但是当我使用下面的代码使用 Axios 调用 API POST 时:
let onestr=[];
onestr=JSON.stringify(apostArray[i]);
alert(onestr);
console.log(onestr);
//alert(JSON.stringify(onestr));
axios
.post('https://localhost:44338/api/txn/',{onestr})
.then(response => {
alert("POST SUCCESS "+response);
alert("POST RESPONSE.DATA "+response.data);
})
.catch(error => {
alert("POST ERROR "+error)
})
}
我得到空值。我究竟做错了什么?
解决方案
推荐阅读
- javascript - 如何用另一个数组更改对象数组的条目
- algorithm - 为什么需要考虑负循环的有向图的最短路径问题?
- flutter - Flutter + Firestore:输入'_InternalLinkedHashMap
' 不是类型 'DocumentSnapshot' 的子类型 - java - 从多个切换按钮计算总价
- ssl - Nginx:如果目录中存在有效证书,则有条件地侦听 SSL 端口
- javascript - 如何根据 React Native 中的语言更改字体大小
- android - Android ViewPager 和 TabLayout:如何在边距之间设置线性(矩形)指示器
- c# - 使用特定列执行“除外”
- python - PyLatex 设置基本示例
- r - 在 R 中使用 ggplot 创建绘图