244
public async addContact(inContact: IContact):
Promise
{
const response: AxiosResponse = await axios.post(
`${config.serverAddress}/contacts`, inContact
);
return response.data;
}
Once more, it’s a simple Axios call, this time a post(), passing inContact as the
second argument. Axios takes care of serializing that to JSON and sending it in the
request body for us. We get back the same object but now with the _id field added, so
that is returned so the caller can add it to the list of contacts for display (we’ll get into all
of that later).
Do'stlaringiz bilan baham: