skip to Main Content

Javascript – How do I fix this error: Query data cannot be undefined. Please make sure to return a value other than undefined from your query function

I have the following code. import Post from "../post/Post"; import "./posts.scss"; import {useQuery} from "@tanstack/react-query"; import {makeRequest} from "../../axios"; //omitted code here const {isLoading, error, data } = useQuery({ queryKey: ["posts"], queryFn: () => { makeRequest.get("/posts").then((res) => { return res.data;…

VIEW QUESTION

Reactjs – LocalStorage with State

I'm using the following code to store cart data into local storage "use client"; import React, { useState, useEffect } from "react"; export default function Home() { const [cartItems, setCartItems] = useState([]); useEffect(() => { const cartItemsData = JSON.parse(localStorage.getItem("cartItems")); if…

VIEW QUESTION
Back To Top
Search