Question:

Problem with JSForce

Stella: 2 weeks ago

I am trying to access the REST API using JSForce. I am connecting fine via OAuth, signing in and being redirected to where I need to be with my access token, etc. After that I am trying to access the data. Problem is, the console is showing nothing back to me.. Which means that the jsforce.browser.on function is not working. See below:

jsforce.browser.init({
                 clientId: 'Works',
                 redirectUri: 'Works'
                 });

jsforce.browser.on('connect', function(conn)
               {
               conn.query('-----', function(err, res)
                          {
                          if (err)
                          {
                            return console.error(err);
                          }
                          console.log(res);
                          console.log("Console");
                          });
               });

This code is supposed to work. Has anybody experienced this problem before? Any idea what is going on here?

Answer:
Claire: 2 weeks ago

Your text says that you connect fine via OAuth, sign in, and get redirected. However, that's not apparent from the code you have posted, which has the pre-login initialization code and the post-connection code but is missing the code to actually login:

jsforce.browser.login();

So, it would appear that you need to add that code to login. (If you already have it then please comment and/or revise your question to better reflect the code you have in place.)