Browse Source

index: de-privatize `fetch`

master
Guillermo Rauch 9 years ago
parent
commit
69fda5cf98
  1. 10
      lib/index.js

10
lib/index.js

@ -74,7 +74,7 @@ export default class Now extends EventEmitter {
const deployment = await retry(async (bail) => {
if (this._debug) console.time('> [debug] /now/create');
const res = await this._fetch('/now/create', {
const res = await this.fetch('/now/create', {
method: 'POST',
body: {
forceNew,
@ -164,7 +164,7 @@ export default class Now extends EventEmitter {
if (this._debug) console.time(`> [debug] /sync #${attempt} ${names.join(' ')}`);
const stream = resumer().queue(data).end();
const res = await this._fetch('/now/sync', {
const res = await this.fetch('/now/sync', {
method: 'POST',
headers: {
'Content-Type': 'application/octet-stream',
@ -198,7 +198,7 @@ export default class Now extends EventEmitter {
const { deployments } = await retry(async (bail) => {
if (this._debug) console.time('> [debug] /list');
const res = await this._fetch('/now/list' + query);
const res = await this.fetch('/now/list' + query);
if (this._debug) console.timeEnd('> [debug] /list');
// no retry on 4xx
@ -224,7 +224,7 @@ export default class Now extends EventEmitter {
await retry(async (bail) => {
if (this._debug) console.time('> [debug] /remove');
const res = await this._fetch('/now/remove', {
const res = await this.fetch('/now/remove', {
method: 'DELETE',
body: data
});
@ -277,7 +277,7 @@ export default class Now extends EventEmitter {
return this._syncAmount;
}
_fetch (_url, opts = {}) {
fetch (_url, opts = {}) {
opts.headers = opts.headers || {};
opts.headers.authorization = `Bearer ${this._token}`;
return this._agent.fetch(_url, opts);

Loading…
Cancel
Save