rubber-blueR
Refine3y ago
5 replies
rubber-blue

Problems Using Axios to Query from AWS API Gateway

Hi All,

I am going through the docs and I setup a manual data provider so i can provide my AWS Cognito AccessToken as a bearer token under the Authorization header in Axios, but some reason, when my data provider makes the request with getList it doesn't send the proper headers.

This is my code on my organizations page, that simply tries to list out all the organizations:
const { data: organizationData, isLoading: organizationIsLoading } = useList({
    resource: "organizations",
    queryOptions: {
      enabled: !!dataGridProps?.rows,
    },
  });


And in my data provider for getList, I added the following to try to setup the Auth headers:
const { data, headers } = await axiosInstance.get(`${url}?${stringify(query)}&${stringify(queryFilters)}`, {
      headers: {
        "Content-Type": "application/json; charset=utf-8",
        Accept: "application/json",
        Authorization: `Bearer ${localStorage.getItem("token")}`,
      },
    });


Also, I cannot seem to be able to console.log anything from within my dataProvider functions, in an attempt to debug what's going on, like getList, is this normal?
image.png
Was this page helpful?