Listing Mailboxes
Listing mailboxes is just like listing contacts in terms of the call to the server, and we find
a similar listMailboxes() method for it:
public async listMailboxes(): Promise {
const response: AxiosResponse =
await axios.get(`${config.serverAddress}/mailboxes`);
return response.data;
}
Yep, just a slightly different URL to call and different interfaces, but otherwise, the
same as listing contacts.
Listing Messages
Listing messages in a mailbox is just a trivial thanks to the listMessages() method:
public async listMessages(inMailbox: string):
Promise {
const response: AxiosResponse = await axios.get(
`${config.serverAddress}/mailboxes/${inMailbox}`
);
return response.data;
}
Here, we just need the path of the mailbox to get messages for, which we get from the
inMailbox argument. Then, it’s just an Axios get() call again.
Chapter 9 Delivering the gooDs: MailBag, the Client
246
Do'stlaringiz bilan baham: |