I'm calling 2 REST API endpoints using Axios in NodeJS.I'm trying to make that the code executes line by line but the second (viewProfile()) function doesn't wait for generateId();
const generateId = async (data) => {
const options = optionsBuilder("post","profile", data);
try {
const response = await axios(options);
id = response.data.id;
console.log(id);
} catch (error) {
console.error(error);
}
}
const viewProfile = async (profileId) => {
console.log('Test 2', profileId);
const path = `blog/${profileId}`;
const options = optionsBuilder("get", path);
try {
const response = await axios(options);
console.log(response.data);
} catch (error) {
console.log(error);
}
}
}
...
generateId(data);
viewProfile(profileId);