Skip to content

Commit

Permalink
Add Fetch path to tsconfig; update response types (#80)
Browse files Browse the repository at this point in the history
* Add fetch to tsconfig

* Fix type errors
  • Loading branch information
jeffdaley authored Mar 13, 2023
1 parent c11e483 commit 2889f3e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion web/app/components/new/doc-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default class NewDocFormComponent extends Component<NewDocFormComponentSi
title: cleanString(this.title),
}),
})
.then((response) => response.json());
.then((response) => response?.json());

// Wait for document to be available.
await timeout(AWAIT_DOC_DELAY);
Expand Down
2 changes: 1 addition & 1 deletion web/app/routes/authenticated/drafts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class DraftsRoute extends Route {
"/api/v1/drafts?" +
this.createDraftURLSearchParams(params, ownerFacetOnly)
)
.then((response) => response.json());
.then((response) => response?.json());
return response;
} catch (e: unknown) {
console.error(e);
Expand Down
3 changes: 2 additions & 1 deletion web/app/routes/authenticated/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default class SettingsRoute extends Route {
const allProducts = await this.fetchSvc
.fetch("/api/v1/products")
.then((resp) => {
return resp.json()})
return resp?.json();
})
.catch((err) => {
console.log(`Error requesting products: ${err}`);
});
Expand Down
18 changes: 9 additions & 9 deletions web/app/services/authenticated-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ export default class AuthenticatedUserService extends Service {
*/
fetchSubscriptions = task(async () => {
try {
let response = await this.fetchSvc.fetch("/api/v1/me/subscriptions", {
method: "GET",
headers: {
"Hermes-Google-Access-Token":
this.session.data.authenticated.access_token,
},
});
let subscriptions: string[] = await response.json();
let subscriptions = await this.fetchSvc
.fetch("/api/v1/me/subscriptions", {
method: "GET",
headers: {
"Hermes-Google-Access-Token":
this.session.data.authenticated.access_token,
},
})
.then((response) => response?.json());

let newSubscriptions: Subscription[] = [];

if (subscriptions) {
// map
newSubscriptions = subscriptions.map((subscription: string) => {
return {
productArea: subscription,
Expand Down
1 change: 1 addition & 0 deletions web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"hermes/*": ["app/*"],
"hermes/mirage/*": ["mirage/*"],
"*": ["types/*"],
"fetch": ["node_modules/ember-fetch"],
"ember-cli-flash/*": ["node_modules/ember-cli-flash"]
}
},
Expand Down

0 comments on commit 2889f3e

Please sign in to comment.