It's my first posting here so sorry if I'm not giving enough information about my problem. I'm not that familiar with coding but I'm trying to get this function to return the url of files in my dropbox account:
var imgUrl = function(path) {
dropbox({
resource: 'sharing/list_shared_links',
parameters: {
'path': '/' + path
}
}, (err, result, response) => {
if (err) {
return console.log(err);
}
res = result.links[0].url;
res = res.replace('dl=0', 'dl=1');
return res;
});
}
console.log(imgUrl("img/tilesets/Inside_A1.png")); //undefined
But console.log(imgUrl("img/tilesets/Inside_A1.png"));
for example, shows undefined. I does give the url when I change return res
to return console.log(res)
but I can't make it give the result without console.log. Can someone please tell me how to return the url when imgUrl(path)
is used?