Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fetch from auth #929

Merged
merged 3 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dropbox",
"version": "10.27.0",
"version": "10.27.1",
"registry": "npm",
"description": "The Dropbox JavaScript SDK is a lightweight, promise based interface to the Dropbox v2 API that works in both nodejs and browser environments.",
"main": "cjs/index.js",
Expand Down
10 changes: 1 addition & 9 deletions src/dropbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import DropboxAuth from './auth.js';
import { baseApiUrl, httpHeaderSafeJson } from './utils.js';
import { parseDownloadResponse, parseResponse } from './response.js';

let fetch;

const b64 = typeof btoa === 'undefined'
? (str) => Buffer.from(str).toString('base64')
: btoa;
Expand Down Expand Up @@ -53,19 +51,13 @@ export default class Dropbox {
constructor(options) {
options = options || {};

if (typeof window !== 'undefined') {
fetch = window.fetch.bind(window);
} else {
fetch = require('node-fetch'); // eslint-disable-line global-require
}

if (options.auth) {
this.auth = options.auth;
} else {
this.auth = new DropboxAuth(options);
}

this.fetch = options.fetch || fetch;
this.fetch = options.fetch || this.auth.fetch;
this.selectUser = options.selectUser;
this.selectAdmin = options.selectAdmin;
this.pathRoot = options.pathRoot;
Expand Down