Why get only empty array in data even if i call from postman got the data ?
Unanswered
Flemish Giant posted this in #help-forum

Flemish GiantOP
export const ContentProvider = ({
children,
}: {
children: React.ReactNode;
}) => {
const [contents, setContents] = useState<cardInterface[]>([]);
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
const { data: session } = useSession();
const fetchContent = async () => {
setLoading(true);
setError(null);
try {
// const data = await getContent();
const response = await axios.get(
http://localhost:3001/content?id=${session.id},
{
method: "get",
headers: {
"Content-Type": "application/json",
Authorization: Bearer ${session?.accessToken},
},
}
);
const data = response.data.content;
console.log("DATA", data);
setContents(data);
} catch (error) {
setError("Error in fetching the Card");
} finally {
setLoading(false);
}
}; i am fethc the data 1st by the Content which is comment and now try to call the api by in fetch Content only but both method give me the empty arry why is it so
children,
}: {
children: React.ReactNode;
}) => {
const [contents, setContents] = useState<cardInterface[]>([]);
const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
const { data: session } = useSession();
const fetchContent = async () => {
setLoading(true);
setError(null);
try {
// const data = await getContent();
const response = await axios.get(
http://localhost:3001/content?id=${session.id},
{
method: "get",
headers: {
"Content-Type": "application/json",
Authorization: Bearer ${session?.accessToken},
},
}
);
const data = response.data.content;
console.log("DATA", data);
setContents(data);
} catch (error) {
setError("Error in fetching the Card");
} finally {
setLoading(false);
}
}; i am fethc the data 1st by the Content which is comment and now try to call the api by in fetch Content only but both method give me the empty arry why is it so