Skip to content

Commit 77e420d

Browse files
fix(common): resolve TypeError when opening request from search results (hoppscotch#5842)
Co-authored-by: James George <25279263+jamesgeorge007@users.noreply.github.com>
1 parent b906404 commit 77e420d

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

packages/hoppscotch-common/src/helpers/teams/TeamsSearch.service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@ export class TeamSearchService extends Service {
404404
// has inherited data
405405
if (collection.data) {
406406
const parentInheritedData = JSON.parse(collection.data) as {
407-
auth: HoppRESTAuth
408-
headers: HoppRESTHeader[]
409-
variables: HoppCollectionVariable[]
407+
auth?: HoppRESTAuth
408+
headers?: HoppRESTHeader[]
409+
variables?: HoppCollectionVariable[]
410410
}
411411

412412
const inheritedAuth = parentInheritedData.auth
413413

414-
if (inheritedAuth.authType !== "inherit") {
414+
if (inheritedAuth && inheritedAuth.authType !== "inherit") {
415415
return E.right({
416416
parentID: collectionID,
417417
parentName: collection.title,
@@ -448,9 +448,9 @@ export class TeamSearchService extends Service {
448448
// see if it has headers to inherit, if yes, add it to the existing headers
449449
if (collection.data) {
450450
const parentInheritedData = JSON.parse(collection.data) as {
451-
auth: HoppRESTAuth
452-
headers: HoppRESTHeader[]
453-
variables: HoppCollectionVariable[]
451+
auth?: HoppRESTAuth
452+
headers?: HoppRESTHeader[]
453+
variables?: HoppCollectionVariable[]
454454
}
455455

456456
const inheritedHeaders = parentInheritedData.headers
@@ -494,9 +494,9 @@ export class TeamSearchService extends Service {
494494

495495
if (collection.data) {
496496
const parentData = JSON.parse(collection.data) as {
497-
auth: HoppRESTAuth
498-
headers: HoppRESTHeader[]
499-
variables: HoppCollectionVariable[]
497+
auth?: HoppRESTAuth
498+
headers?: HoppRESTHeader[]
499+
variables?: HoppCollectionVariable[]
500500
}
501501

502502
const variables = parentData.variables

packages/hoppscotch-common/src/services/team-collection.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,9 +1144,9 @@ export class TeamCollectionsService extends Service<void> {
11441144
}
11451145

11461146
const data: {
1147-
auth: HoppRESTAuth
1148-
headers: HoppRESTHeader[]
1149-
variables: HoppCollectionVariable[]
1147+
auth?: HoppRESTAuth
1148+
headers?: HoppRESTHeader[]
1149+
variables?: HoppCollectionVariable[]
11501150
} = parentFolder.data
11511151
? JSON.parse(parentFolder.data)
11521152
: {

0 commit comments

Comments
 (0)