I'm trying to create a shareable link using dropbox api, but the function that I used doesn't return anything.
var ACCESS_TOKEN = "access_token";
var SHARED_LINK = "/example/example.doc";
var dbx = new Dropbox({ accessToken: ACCESS_TOKEN });
var x = dbx.SharingCreateSharedLink({path: SHARED_LINK});
alert(x);
The Dropbox JavaScript SDK returns the API call results asynchronously, not in the return value of the method call.
You can see an example of how to set up the callbacks for the result and error, using then
and catch
, respectively, here:
https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/javascript/basic/index.html#L54
So, for example, your code should look something like this:
var ACCESS_TOKEN = "access_token";
var filePath = "/example/example.doc";
var dbx = new Dropbox({ accessToken: ACCESS_TOKEN });
dbx.sharingCreateSharedLinkWithSettings({path: filePath})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});