I need assistance optimizing my code. What I am trying to achieve is to create a user (partner) and upon completion of the post request, fetch all partners from an API. This includes the newly created partner so that I can access their ID to use in subsequent parts of my code.
The PartnerName will be whatever value the user inputs into the form for posting here.
await axios
.post(newPartnerUrl, { Name: PartnerName }, options)
.then(async () => {
const partnersRes = await axios.get(getPartnersUrl, options);
const partners: IPartner[] = partnersRes.data;
partners.map((partner: IPartner) => {
if (partner.Name === PartnerName) {
partnerId = partner.Id
}
});
});
const PartnerId = partnerId
I would appreciate any help or suggestions on improving this code for better efficiency.