I've got a Chrome extension running while I'm signed in to Salesforce. I want to use themy active SessionID from my session to query Opportunities using Javascript. I've tried passing the sessionID via Ajax but that is not working (getting 401 error).
Here's my code so far:
function processSessionID(sessionID) {
console.log(sessionID);
// Make the REST call here
}
chrome.cookies.getAll({
"domain": "lightning.force.com", "name": "sid"
}, function(cookies) {
for(i = 0; i < cookies.length; i++) {
console.log(cookies[i].value);
var sessionID = cookies[i].value;
processSessionID(sessionID)
}
});
UPDATE: The answer to my question is on the right track. ForceTK does access the API via Javascript - which is what I'm loooking to do. However, it's failing to resolve names on a chrome extension.
How can I make a REST call with with the sessionID to return a list of opportunities?