0
我想用这样的命令,使新行插入来自服务器的响应:等待时间使用爱可信
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
我需要的回应包含包含新创建的用户行的新ID为用户Fred Flintstone提供的信息。但是,由于这是一个数据库,我的脚本可能需要等待更多。我如何控制服务器响应的等待时间?换句话说,
我该怎么做才能告诉javascript Axios命令在触发错误消息之前等待几秒钟,因为“服务器没有响应”。这可能吗?
我的意思是我怎么能告诉javascript axios命令在它触发错误消息之前等待几秒钟,因为“服务器没有响应”? –
你可以创建自己的超时函数,它将等待你想要的毫秒数 –