nextjs-headless-wordpress icon indicating copy to clipboard operation
nextjs-headless-wordpress copied to clipboard

unable to fetch data in nextjs headless WordPress

Open SanjayGitHub00 opened this issue 3 years ago • 4 comments

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; `

SanjayGitHub00 avatar May 28 '21 06:05 SanjayGitHub00

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

imranhsayed avatar Jun 05 '21 17:06 imranhsayed

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.

LarsEjaas avatar Jun 18 '21 20:06 LarsEjaas

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

SanjayGitHub00 avatar Jun 19 '21 17:06 SanjayGitHub00

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

deopronet avatar Jan 19 '22 14:01 deopronet