I am facing this error
i am trying to load events: const { data, isLoading: eventsLoading, error } = useList({
resource: "events",
meta: {
headers: accessToken
? {
Authorization: Bearer ${accessToken},
}
: {},
gqlQuery: DASHBOARD_CALENDAR_UPCOMING_EVENTS_QUERY,
},
queryOptions: {
onError: (error) => {
console.log('Auth token:', localStorage.getItem("access_token"));
console.log('Query error:', error);
}
}
})
but giving this error: undefined
2 Replies
Hi @Shahzaib. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the information provided in the knowledge sources, I can offer some insights into your issue with the
useList
hook in refine. However, the error message you've provided ("undefined") doesn't give much context about the specific problem. Let me suggest a few potential solutions and checks:
1. GraphQL Query: Make sure your DASHBOARD_CALENDAR_UPCOMING_EVENTS_QUERY
is correctly defined. The query should match the structure expected by your GraphQL server. You can refer to the Usage with graphql-tag section in the refine documentation for examples on how to structure your query.
2. Authentication: You're passing an accessToken
in the headers. Ensure that this token is valid and correctly formatted. The JWT Authentication blog post suggests using the following format for the Authorization header:
3. Error Handling: You've included an onError
callback in your queryOptions
. This is good for debugging. Make sure to check your console for any error messages that might provide more details about the issue.
4. Data Provider: Ensure that you're using the correct data provider for your backend. If you're using Hasura, for example, you might need to configure the naming convention. As mentioned in a GitHub issue comment, you can set the naming convention like this:
5. Type Checking: If you're using TypeScript, make sure your types are correctly defined. You can refer to the GitHub issue about DataProvider implementation for examples on how to properly type your data provider methods.
If you're still encountering issues, it would be helpful to see the full error message and stack trace. Also, checking the network tab in your browser's developer tools might provide more insight into what's happening with the API request.
Remember, when using useList
with a GraphQL data provider, you need to provide the gqlQuery
in the meta
object, as you've done. However, make sure that your query is correctly structured and includes all necessary fields.
If you need further assistance, please provide more details about the error you're seeing and the structure of your DASHBOARD_CALENDAR_UPCOMING_EVENTS_QUERY
.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@815486644152958986> Kapa.ai is still learning and improving, please let me know how I did by reacting below.