chrome.extension.sendRequest won't pass object

Recently I had a bit of trouble with Google’s chrome.extension.sendRequest function used in their Chrome extensions API. I found that I was not able to pass my variable outside of the function. I came accross this post that helped explain the reason why. Although I didn’t come up with the ideal solution this did end up working for me in the end:

function doSomething(){
    chrome.extension.sendRequest(options, function(response){
        var thing =;
        //Do something with our variable.
        //The rest of the function goes here before the next bracket

Instead of trying to pass the variable out of chrome.extension.sendRequest I simply just wrapped the whole function in it and that seemed to solve my problem.