const req = new XMLHttpRequest()
req.open('GET','http://localhost:3000/health')
req.send()
req.addEventListener('load',()=>{
this.loading = false
this.apiRes = {
status : req.status,
statusText:req.statusText,
response:JSON.parse(req.response)
}
})
$ npm install axios
axios.get('http://localhost:3000/headlth')
.then(res=>{
this.apiRes = res.data
})
.catch(res=>{
this.error = res.response.data
})
.finally(()=>{
this.loading = false
})
reference