imranhsayed / nextjs-headless-wordpress

🔥 Nextjs Headless WordPress
https://codeytek.com/course/next-js-headless-wordpress-course/
GNU General Public License v3.0
640 stars 161 forks source link

unable to fetch data in nextjs headless WordPress #60

Open SanjayGitHub00 opened 3 years ago

SanjayGitHub00 commented 3 years ago

This is my header component -- ` import { isEmpty } from "lodash"; import Nav from "./Nav";

const Header = ({ headerMenus }) => { // console.log(headerMenus); <- Here i get the menus if (isEmpty(headerMenus)) { return null; } return ( //<Header> // <Nav headerMenus = {headerMenus}/> // </Header> ); }; export default Header; ` when I send data through props to nav I am not getting any data in nav component please help here the code of Nav

` const Nav = ({headerMenus}) =>{ // console.log(headerMenus); <~~ Not getting data here so i can't return anything through this

return; }; export default Nav; `

imranhsayed commented 3 years ago

Please check if you have installed all the plugins described in the README and check your code against this branch https://github.com/imranhsayed/nextjs-headless-wordpress/tree/feature/youtube-tutorial

LarsEjaas commented 3 years ago

Hi @SanjayGitHub00 and @ imranhsayed

I am far from an expert in graphql queries, but I do not understand the last few lines in the get-menus.js file?


export const GET_MENUS = gql`
query GET_MENUS {  
${HeaderFooter}
}  
${MenuFragment}
`

Is it really possible to do a fragment (MenuFragment) outside of the query like this?

To me it looks like a small typo.

SanjayGitHub00 commented 3 years ago

Hi @SanjayGitHub00 and @ imranhsayed

I am far from an expert in graphql queries, but I do not understand the last few lines in the get-menus.js file?


export const GET_MENUS = gql`
query GET_MENUS {  
${HeaderFooter}
}  
${MenuFragment}
`

Is it really possible to do a fragment (MenuFragment) outside of the query like this?

To me it looks like a small typo.

try it and see the result

deopronet commented 2 years ago

This is my header component -- ` import { isEmpty } from "lodash"; import Nav from "./Nav";

const Header = ({ headerMenus }) => { // console.log(headerMenus); <- Here i get the menus if (isEmpty(headerMenus)) { return null; } return ( //<Header> // <Nav headerMenus = {headerMenus}/> // </Header> ); }; export default Header; ` when I send data through props to nav I am not getting any data in nav component please help here the code of Nav

` const Nav = ({headerMenus}) =>{ // console.log(headerMenus); <~~ Not getting data here so i can't return anything through this

return; }; export default Nav; `

Same problem ! I already install all plugins but I'm not getting data