Angular - HTTP Client
This Angular component code snippet has a bug:
What is the issue with setting
loading = false;
error = '';
fetchData() {
this.loading = true;
this.error = '';
fetch('api/data')
.then(() => {
this.loading = false;
this.error = 'No error';
})
.catch(() => {
this.loading = false;
this.error = 'Failed';
});
}What is the issue with setting
error to 'No error' on success?