Passing data from service to controller
<p>I have created a service with the purpose of accessing an API. I need to return data to my controller but am unsure how to do this as I completely new to sails.</p>

<p>My Service:</p>

<pre><code>// API call to get the ID of contact within Get Response with email address
getContact: function(options) {

    // establish connection to API
    var api = new getResponse(apiKey, apiUrl);

    var contact = api.getContactsByEmail(options.email, null, null, function (response) {
        JSON.stringify(response);
        console.log(JSON.stringify(response));
    });

    return contact;

},
</code></pre>

<p>I know the API call is working as when I log the response I get the correct response:</p>

<p>{"success":true,"data":{"error":null,"id":1,"result":{"sds":{"ip":null,"name":"Full Name","origin":"api","cycle_day":0,"email":"email@email.com","campaign":"id","created_on":"date","changed_on":null}}}}</p>

<p>My Controller:</p>

<pre><code>index: function(req, res) {

    var contact = GetresponseService.getContact({email: 'email@email.com'});

    console.log(contact);
    return res.send(contact);

}
</code></pre>

<p>I want to retrieve the ID value but when I log the value of contact I get undefined. I think my problem is related to the scope but not sure.</p>

<p>Can anyone point me in the right direction?</p>