Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
node fetch api
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed May 15, 2018
1 parent 5850a59 commit 17cf059
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"electron-updater": "2.21.4",
"keytar": "4.1.0",
"lunr": "2.1.6",
"node-fetch": "2.1.2",
"node-forge": "0.7.1",
"rxjs": "5.5.6",
"zone.js": "0.8.19"
Expand Down
4 changes: 1 addition & 3 deletions src/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,10 @@ export class ApiService implements ApiServiceAbstraction {
}

private async handleTokenState(): Promise<string> {
let accessToken: string;
let accessToken = await this.tokenService.getToken();
if (this.tokenService.tokenNeedsRefresh()) {
const tokenResponse = await this.doRefreshToken();
accessToken = tokenResponse.accessToken;
} else {
accessToken = await this.tokenService.getToken();
}

return 'Bearer ' + accessToken;
Expand Down
15 changes: 15 additions & 0 deletions src/services/nodeApi.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Utils } from '../misc/utils';

import { ApiService } from './api.service';

import { PlatformUtilsService } from '../abstractions/platformUtils.service';
import { TokenService } from '../abstractions/token.service';

import * as fetch from 'node-fetch';

export class NodeApiService extends ApiService {
constructor(tokenService: TokenService, platformUtilsService: PlatformUtilsService,
logoutCallback: Function) {
super(tokenService, platformUtilsService, logoutCallback);
}
}

0 comments on commit 17cf059

Please sign in to comment.