Created
February 17, 2016 10:02
-
-
Save bernardo-cs/8a86f636d45423618209 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var API = function () { | |
| }; | |
| API.prototype.login = function(username, password) { | |
| console.log("request username and pw to server..."); | |
| this.auth_token = "nhonhonho"; | |
| }; | |
| API.prototype.getUserById = function(user_id) { | |
| if (this.auth_token){ | |
| console.log("request user with id " + user_id + " with token " + this.auth_token); | |
| return { username: 'Bernardo', email: 'bersimoes' } | |
| }else{ | |
| console.log("you need to login first"); | |
| } | |
| }; | |
| var my_api = new API(); | |
| my_api.getUserById('1234'); | |
| my_api.login('bernardo', 'password'); | |
| my_api.getUserById('1234'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment