You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to fetch data from slug [...slug].js page but showing undefined.
slug page code here
import {GET_PAGES_URI} from '../queries/pages/get-pages';
import {isEmpty} from 'lodash';
import {GET_PAGE} from '../queries/pages/get-page';
import {useRouter} from 'next/router';
import client from '../apollo/client';
import Layout from '../components/layout';
const Page = ( {data} ) => {
console.log('data', data);
const router = useRouter();
// If the page is not yet generated, this will be displayed
// initially until getStaticProps() finishes running
if ( router.isFallback ) {
return <div>Loading...</div>;
}
return (
<>
<Layout data={data}>
{router?.query?.slug.join("/")}
</Layout>
</>
);
Trying to fetch data from slug [...slug].js page but showing undefined.
slug page code here
import {GET_PAGES_URI} from '../queries/pages/get-pages';
import {isEmpty} from 'lodash';
import {GET_PAGE} from '../queries/pages/get-page';
import {useRouter} from 'next/router';
import client from '../apollo/client';
import Layout from '../components/layout';
const Page = ( {data} ) => {
console.log('data', data);
}
export default Page;
export async function getStaticProps( {params} ) {
const {data, loading, networkStatus} = await client.query( {
query: GET_PAGE,
variables: {
uri: params?.slug.join( '/' ),
},
} );
}
export async function getStaticPaths() {
const {data} = await client.query( {
query: GET_PAGES_URI
});
}
The text was updated successfully, but these errors were encountered: