function retrieveDataFromProfiles(){
const fs = require('fs')
fs.readFile('src/data/profileInfo.json', function(error, data){
if(error){
alert(error);
}
var profileData = JSON.parse(data);
//retrieves the JSON data of profiles
return profileData;
});
}
I am attempting to extract the JSON data from this function and assign it to a variable in another function. However, I am uncertain about the correct method to achieve this, as the traditional return approach is not effective. I have been advised to utilize either a promise or async function, but I lack clarity on how to proceed with that.