shows api error message

This commit is contained in:
Hongbo Wu
2023-10-14 13:18:40 +08:00
parent a20b956e26
commit 4ae6c476f8
2 changed files with 10 additions and 4 deletions

View File

@ -6,6 +6,9 @@ interface SearchResponse {
edges: Edge[]
}
}
errors?: {
message: string
}[]
}
interface Edge {
@ -28,7 +31,6 @@ interface Label {
}
export const search = async (
userId: string,
apiEndpoint: string,
auth: string,
query: string
@ -75,6 +77,12 @@ export const search = async (
}
)
if (response.data.errors) {
console.error(response.data.errors)
return []
}
const edges = response.data.data.search.edges
if (edges.length === 0) {
return []
@ -89,14 +97,13 @@ export const search = async (
}
export const filterPage = async (
userId: string,
apiEndpoint: string,
auth: string,
filter: string,
pageId: string
): Promise<Page | null> => {
filter += ` includes:${pageId}`
const pages = await search(userId, apiEndpoint, auth, filter)
const pages = await search(apiEndpoint, auth, filter)
return pages.length > 0 ? pages[0] : null
}

View File

@ -93,7 +93,6 @@ export const triggerActions = async (
}
const filteredPage = await filterPage(
userId,
apiEndpoint,
authToken,
rule.filter,