I'm trying to test the realistic performance of memory and CPU load on a server by making POST requests and recieving a response within a setInterval()
function.
(我正在尝试通过发出POST请求并在setInterval()
函数中接收响应来测试服务器上内存和CPU负载的实际性能。)
The issue is, my function will always run regardless of whether a successful response is given, I'd like to be able to pause the function until the .then()
function comes back with a response, and then resume my interval, I've got the following in the mounted()
hook in my Vue JS project:(问题是,无论是否给出成功的响应,我的函数将始终运行,我希望能够暂停该函数,直到.then()
函数返回响应,然后恢复我的间隔,在我的Vue JS项目的mounted()
挂钩中有以下内容:)
mounted () {
setInterval(() => {
this.$http.post('http://example.com/api', {
apiKey: this.formData.one,
application: this.formData.two
}, {
emulateJSON: true,
headers: {
'Content-Type': 'multipart/form-data'
}
}).then(function (response) {
console.log('Success')
}).catch(function (err) {
console.log('Error')
}).bind(this)
}, 500)
}
ask by Ryan Holton translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…