I have this submit function that runs two functions when clicked on.
My issue is that props.updateValues()
is executed before createAffiliation(values)
How can I change the order of the execution?
const onSubmit = () => {
createAffiliation(values)
props.updateValues();
}
createAffiliation:
export function createAffiliation(anknytning: Anknytning) {
return axios
.post(Endpoints.affiliationData, anknytning)
.then((response: AxiosResponse<any>) => {
console.table("Created affiliation", anknytning);
return Promise.resolve(response.data);
})
.catch(reason => {
console.error("Could not create affiliation", reason);
return Promise.reject(reason);
});
}