API Performance - Frontend
Standards
- Always attempt to validate input before sending
- Make as few assumptions about data being available as possible. What if a a value is undefined?
- Use await/async as described below.
- Use regular error handling
Example request
async task_list_api() {
this.loading = true
try {
const response = await axios.post(`/api/v1/job/${this.job_id}/task/list`, {
'date_from': this.date ? this.date.from : undefined,
'date_to': this.date ? this.date.to : undefined,
'job_id': this.job_id,
'mode_data': this.mode_data,
'incoming_directory_id': this.incoming_directory ? this.incoming_directory.directory_id : undefined,
'status': this.task_status
})
if (response.data.log.success == true) {
this.task_list = response.data.task_list
this.pending_initial_dir_sync = response.data.pending_initial_dir_sync;
}
return response
} catch (error) {
console.log(error);
return false;
} finally {
this.loading = false
}
},
Updated over 3 years ago