How would I access buildLoginUrl() in my call to login()? The first here isn't being printed, and I think it's because the call to login() is never returned.
main.js:
$(document).ready(function() {
// login function to kick off the authorization
function login(callback) {
console.log("here2");
// builds the login URL for user after clicking login button
function buildLoginUrl(scopes) {
console.log("here3");
return 'https://accounts.spotify.com/authorize?client_id=' + clientID +
'&redirect_uri=' + redirectURI +
'&scope=' + scopes +
'&response_type=token';
}
// other stuff
}
// event listeners
$("#login").click(function() {
// call the login function, we'll get back the accessToken from it
console.log("here1");
login(function(accessToken) {
// callback function from login, gives us the accessToken
//buildLoginUrl(scopes);
var request = getUserData(accessToken);
console.log("here");
request.get(options, function(error, response, body) {
console.log(body);
});
// other stuff
});
});
Console:
here1
here2
here4
buildLoginUrlanywhere in your example. Where exactly do you want to call it?buildLoginUrl()is never called sohere3will never show.login()function never calls thecallbackfunction and that's whyhereis never logged.login()because that was given to me for this problem, but I can edit the code withinlogin(function(accessToken)). I don't think I have to callbuildLoginUrl, but I'm not sure whyhereisn't printed to the console