Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use SessionConfig #25

Open
pierratono opened this issue Oct 1, 2020 · 1 comment
Open

Unable to use SessionConfig #25

pierratono opened this issue Oct 1, 2020 · 1 comment

Comments

@pierratono
Copy link

pierratono commented Oct 1, 2020

When i use provided code to config session callbacks

i get this error:
UnhandledPromiseRejectionWarning: ReferenceError: sessions is not defined

@habbes how can i resolve this?

@harmonizerblinks
Copy link

you have to declare a variable called "sessions" before you can used session config

Example:
let sessions = {};
menu.sessionConfig({
start: (sessionId, callback) => {
// initialize current session if it doesn't exist
// this is called by menu.run()
if (!(sessionId in sessions)) sessions[sessionId] = {};
callback();
},
end: (sessionId, callback) => {
// clear current session
// this is called by menu.end()
delete sessions[sessionId];
callback();
},
set: (sessionId, key, value, callback) => {
// store key-value pair in current session
sessions[sessionId][key] = value;
callback();
},
get: (sessionId, key, callback) => {
// retrieve value by key in current session
let value = sessions[sessionId][key];
callback(null, value);
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants