Skip to content

Instantly share code, notes, and snippets.

@robisatthefunction
Last active June 2, 2025 18:54
Show Gist options
  • Save robisatthefunction/2eeff8394914dedb815f9229c9f9a79d to your computer and use it in GitHub Desktop.
Save robisatthefunction/2eeff8394914dedb815f9229c9f9a79d to your computer and use it in GitHub Desktop.
function getUserInfo(user_id){
// Add logic to check if (store_id_boolean is in local storage and not expired value)
fetch('https://tapi.optimizely.com/api/js/odds/project/<project_id>?project=<project_id>&c_user_id=' + user_id).then(function (response) {
// The API call was successful!
return response.json();
}).then(function (data) {
// Recommended to cache this user data for a period of time so you are not making requests for user info on every page load
return data
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment