is something like that:
{
success: true,
data: [
{
deleted: false,
id: '01c2313c-13eb-4bb6-86fd-89ef4cdbfba0',
chat_id: 123456789,
first_name: 'Michael',
last_name: 'Fantoni',
email: 'hello@gmail.com',
created_at: '2020-08-11T12:45:16.000Z',
}
],
count: 1,
pagination: {},
message: null
}
I'm using Axios in my SDK, so essentially a get request for customers is handled as follow:
public async getCustomers(): Promise<Array<Customer>> {
return await this.request.get(this.path)
}
where this.request is the Axios instance and this.path is the route. Here comes the problem:
as you can see the Promise should return an array of customers, but the API response looks different.
How would you manage that? Should I create an interceptor that get only the data content?
Doing this I'll lose the pagination which is available for specific get routes.
well you either change the signature or change the implementation, to loose pagination etc
getCustomers(page: number) ?
Обсуждают сегодня