let userInsert = new Promise((resolve, reject) => {
db.query('INSERT INTO users (email, password) VALUES (?, ?)', [user.email, user.password], err => {
if(err) {
reject(err);
return;
}
resolve();
});
});
this.getDataForPlaces = function(addresses){
return Promise.all(Array.prototype.map.call(addresses, function(address) {
return getLocationDesc(address);
}));
};
function getLocationDesc(address) {
return new Promise(function(resolve, reject) {
var parameters = [];
var message = {
'action' : 'http://api.yelp.com/v2/search',
'method' : 'GET',
'parameters' : parameters
};
OAuth.setTimestampAndNonce(message);
OAuth.SignatureMethod.sign(message, accessor);
var parameterMap = OAuth.getParameterMap(message.parameters);
$.ajax({
url : message.action,
cache : true,
method : message.method,
data : parameterMap,
dataType : 'jsonp',
jsonp : 'callback',
success : resolve,
error : reject
});
});
};