shows api error message
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
@ -93,7 +93,6 @@ export const triggerActions = async (
|
||||
}
|
||||
|
||||
const filteredPage = await filterPage(
|
||||
userId,
|
||||
apiEndpoint,
|
||||
authToken,
|
||||
rule.filter,
|
||||
|
||||
Reference in New Issue
Block a user