I am trying to get the response from sendResponse to chrome.runtime.sendMessage, but its always showing undefined, below is my code:
chrome.runtime.sendMessage(JSON.stringify(contact), function(response) {
console.log('Response: ', response); // This is showing undefined
});
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
contact.addContact(request, function() {
sendResponse({success: 'true'});
});
});
So when I pass sendResponse({success: true}) that should be received in callback on chrome.runtime.sendMessage but instead of that its showing undefined.