I am trying to get an ID then use that id in another function, I get the error:
There has been a problem with your fetch operation: undefined
getPreferences()
.then((id) => updatePreferences(id))
.then(() => console.log('Success'))
.catch(function (error) {
console.log(
'There has been a problem with your fetch operation: ' +
error.message,
);
throw error;
});
Async functions:
export const getPreferences = async () => {
try {
const response = await get(API_GET_PREFERENCES, null, null);
return response;
} catch (e) {
logCustomException('Error getting preferences id', e);
throw e;
}
};
export const updatePreferences = async (id) => {
try {
const response = await put(API_UPDATE_PREFERENCES, null, id, null, false);
return response;
} catch (e) {
logCustomException('Error getting preferences id', e);
throw e;
}
};