Skip to content

Commit

Permalink
Fix #78: GetSharing should return undefined when missing
Browse files Browse the repository at this point in the history
  • Loading branch information
chenilim committed Mar 17, 2021
1 parent c7b6ebe commit 2681b89
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions webapp/src/octoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class OctoClient {
Utils.log(`OctoClient serverUrl: ${this.serverUrl}`)
}

private async getJson(response: Response, defaultValue: any = {}): Promise<any> {
private async getJson(response: Response, defaultValue: any): Promise<any> {
// The server may return null or malformed json
try {
const value = await response.json()
Expand All @@ -47,7 +47,7 @@ class OctoClient {
return false
}

const responseJson = (await this.getJson(response)) as {token?: string}
const responseJson = (await this.getJson(response, {})) as {token?: string}
if (responseJson.token) {
localStorage.setItem('sessionId', responseJson.token)
return true
Expand All @@ -67,7 +67,7 @@ class OctoClient {
headers: this.headers(),
body,
})
const json = (await this.getJson(response))
const json = (await this.getJson(response, {}))
return {code: response.status, json}
}

Expand All @@ -79,7 +79,7 @@ class OctoClient {
headers: this.headers(),
body,
})
const json = (await this.getJson(response))
const json = (await this.getJson(response, {}))
return {code: response.status, json}
}

Expand All @@ -98,7 +98,7 @@ class OctoClient {
if (response.status !== 200) {
return undefined
}
const user = (await this.getJson(response)) as IUser
const user = (await this.getJson(response, {})) as IUser
return user
}

Expand All @@ -108,7 +108,7 @@ class OctoClient {
if (response.status !== 200) {
return undefined
}
const user = (await this.getJson(response)) as IUser
const user = (await this.getJson(response, {})) as IUser
return user
}

Expand Down Expand Up @@ -249,7 +249,7 @@ class OctoClient {
if (response.status !== 200) {
return undefined
}
const sharing = (await this.getJson(response)) as ISharing
const sharing = (await this.getJson(response, undefined)) as ISharing
return sharing
}

Expand Down Expand Up @@ -279,7 +279,7 @@ class OctoClient {
if (response.status !== 200) {
return undefined
}
const workspace = (await this.getJson(response)) as IWorkspace
const workspace = (await this.getJson(response, undefined)) as IWorkspace
return workspace
}

Expand Down

0 comments on commit 2681b89

Please sign in to comment.