Back

Best practice for await api call

Copy Below Code View As A Text File Show Text Only Show API Edit Code
                            

const { data: formattedData } = await patientService.getPatientsByPracticeId(practiceId); setState((st) => { return { ...st, data: formattedData.rows ? [...formattedData.rows] : [], count: formattedData.count, } }); if you want to do this and overriding .then() method, you can restructure the response object.