Skip to content

Commit

Permalink
Typescript was stripping out the require of node-fetch b/c it thought…
Browse files Browse the repository at this point in the history
… it wasn’t used.
  • Loading branch information
jonathandann committed Sep 2, 2019
1 parent edfb7ba commit 6d12a3c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ function url(path: Path): string {
return `https://mob.yalehomesystem.co.uk/yapi/${path}/`
}

function headersWithAccessToken(accessToken: string): Headers {
return new Headers({
function headersWithAccessToken(accessToken: string): NodeFetch.HeadersInit {
return {
Authorization: `Bearer ${accessToken}`,
})
}
}

export async function getAccessToken(
Expand All @@ -27,7 +27,7 @@ export async function getAccessToken(
username
)}&password=${encodeURIComponent(password)}`

let response = await fetch(url(Path.auth), {
let response = await NodeFetch.default(url(Path.auth), {
method: 'POST',
body: payload,
headers: {
Expand Down Expand Up @@ -59,7 +59,7 @@ export async function setStatus(
)
}

let response = await fetch(url(Path.panelMode), {
let response = await NodeFetch.default(url(Path.panelMode), {
method: 'POST',
body: `area=1&mode=${alarmState}`,
headers: headersWithAccessToken(accessToken),
Expand All @@ -76,7 +76,7 @@ export async function getStatus(accessToken: string): Promise<AlarmState> {
)
}

let response = await fetch(url(Path.panelMode), {
let response = await NodeFetch.default(url(Path.panelMode), {
method: 'GET',
headers: headersWithAccessToken(accessToken),
})
Expand Down

0 comments on commit 6d12a3c

Please sign in to comment.