Can';t使用dropbox javascript sdk创建共享链接
我试图使用dropbox api创建一个可共享的链接,但是我使用的函数没有返回任何内容Can';t使用dropbox javascript sdk创建共享链接,javascript,dropbox,dropbox-api,dropbox-sdk-js,Javascript,Dropbox,Dropbox Api,Dropbox Sdk Js,我试图使用dropbox api创建一个可共享的链接,但是我使用的函数没有返回任何内容 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); D
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);
Dropbox JavaScript SDK异步返回API调用结果,而不是方法调用的返回值 您可以在此处看到一个示例,说明如何分别使用
then
和catch
为结果和错误设置回调:
例如,您的代码应该如下所示:
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);
});