src/dropbox.js
function (path) {
    var url = 'https://api.dropbox.com/2/sharing/list_shared_links';
    var options = {
      body: {
        path: getDropboxPath(path),
        direct_only: true
      }
    };

    return this._request('POST', url, options).then((response) => {
      if (response.status !== 200 && response.status !== 409) {
        return Promise.reject(new Error('Invalid response status: ' + response.status));
      }

      var body;

      try {
        body = JSON.parse(response.responseText);
      } catch (e) {
        return Promise.reject(new Error('Invalid response body: ' + response.responseText));
      }

      if (response.status === 409) {
        return Promise.reject(new Error('API error: ' + response.error_summary));
      }

      if (!body.links.length) {
        return Promise.reject(new Error('No links returned'));
      }

      return Promise.resolve(body.links[0].url);
    }, (error) => {
      error.message = 'Could not get link to a shared file or folder ("' + path + '"): ' + error.message;
      return Promise.reject(error);
    });
  }
function (path) {
    var url = 'https://api.dropbox.com/2/sharing/list_shared_links';
    var options = {
      body: {
        path: getDropboxPath(path),
        direct_only: true
      }
    };

    return this._request('POST', url, options).then((response) => {
      if (response.status !== 200 && response.status !== 409) {
        return Promise.reject(new Error('Invalid response status: ' + response.status));
      }

      var body;

      try {
        body = JSON.parse(response.responseText);
      } catch (e) {
        return Promise.reject(new Error('Invalid response body: ' + response.responseText));
      }

      if (response.status === 409) {
        return Promise.reject(new Error('API error: ' + response.error_summary));
      }

      if (!body.links.length) {
        return Promise.reject(new Error('No links returned'));
      }

      return Promise.resolve(body.links[0].url);
    }, (error) => {
      error.message = 'Could not get link to a shared file or folder ("' + path + '"): ' + error.message;
      return Promise.reject(error);
    });
  }
Requests the link for an already-shared file or folder.

@param {string} path - path to the file or folder

@returns {Promise} A promise for the shared link

@private