Learn

Certain grant types have specific functions that must be implemented for them to work. The Client Credentials grant type must have the getUserFromClient() function implemented to be used.

The getUserFromClient() function is invoked to retrieve the user associated with the specified client. We are not using a user in our application so we can return an empty object. However, leaving out this function declaration will throw an error when using the Client Credentials grant type!

const getUserFromClient = (client) => { return {}; }

Finally, we export the function from model.js so that it can be used from other files. We can do this using module.exports object.

module.exports = { // Other modules to export getUserFromClient: getUserFromClient }

Instructions

1.

Within model.js define a function expression named getUserFromClient() that takes one argument, client using ES6 Arrow function expressions..

2.

Return an empty object from the getUserFromClient() function.

3.

We’ll have to export the function from model.js using the module.exports object. Export getUserFromClient() as getUserFromClient.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?