I made a button to use an api to restart an application
That button works well. However, when it comes to alert popup, OK button sometimes doen't work. Even I click and click again, it doesn't close the alert popup. If I click it again after waiting a little moment like three seconds, then it close the alert popup normally. I don't know what will be the real problem, because I didn't experience this before. Can it be a browser(chrome)'s problem? Or vue framework's or nuxt framework's? I use nuxt framework in this code.
The code is below
restartApp.vue
<template>
<button>restart</button>
</template>
<script>
import {
createRestart
} from '@/api/agent'
export default {
methods:{
restart() {
if (confirm('Restart agent?')) {
createRestart().then((res) => {
if (res.status == 200) {
alert('Agent is restarted')
}else{
alert("Agent isn't restarted")
}
}).catch((err)=>{
alert('Agent has a error to restart >>', err)
})
}
},
}
}
</script>
@/api/agent.js
import axios from "axios";
import { headers } from "../config/env";
export function createRestart() {
return axios.post("/api/agent/schedule/restart", {}, { headers });
}
/api.js
//(...)
router.post('/agent/schedule/restart', async (req, res) => {
const axiosInstance = axios.create({ timeout:3000 });
try {
const result = await axiosInstance.post(
"http://agentUrl" + '/v1/restart',
{},
config
)
res.json(result.data)
} catch (err) {
console.log(err)
res.sendStatus(500)
}
})
//(...)