javascript - 我对如何将数据发送到 enpoint 有疑问
问题描述
早上好我有一个问题,我有一个表单对象和一个字段变量,当我用XXX函数发出一个post请求时,它没有设置字段中的值,当我发送到时它会抛出一个basio数组指出。
我分享代码
async function createForm() {
try {
if ( form == null) {
form = {
'deviceId' : deviceId,
'closeTimestamp' : undefined,
'fields' : [],
};
fields.push({
"id" : fieldId,
"startTimestamp": parseInt(Date.now()/1000),
"stopTimestamp" : undefined,
"observation" : null
})
console.log('formcreate',form)
}
const operation = await createCargoTransport(deviceId, form)
console.log('data al crear ===>',operation)
form.id = operation.id;
} catch (e) {
if ( e.message.includes('not identified') ) {
fields = [];
form = {};
clearSession();
}
}
isFormReady = false;
}
在谷歌控制台中,我看到它没有将数据保存在字段中
{deviceId:154,字段:[]} deviceId:154 字段:[]
解决方案
推荐阅读
- javascript - 中断以角度 9 运行的每个循环
- python - gmail api:从线程获取最新的 2 封电子邮件
- python - 在 python 类中导入另一个类并访问超类属性
- javascript - 想要在鼠标滚轮滚动 Nuxt js 中水平滚动
- batch-file - 设置变量 2 等于变量 1
- python - 如何预处理小于 256 x 256 的 ImageNet 数据?
- qt - QML TableView 和 Headerview 与 QSortFilterProxyModel
- javascript - 仅更新反应中一项的状态
- r - 无法在 Linux Mint 18 上更新 R
- python-3.x - 对象检测应用程序卡在 RingBuffer - 分配了 4 个缓冲区