Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to fetch data in nextjs headless WordPress #60

Open
SanjayGitHub00 opened this issue May 28, 2021 · 4 comments
Open

unable to fetch data in nextjs headless WordPress #60

SanjayGitHub00 opened this issue May 28, 2021 · 4 comments
Labels

Comments

@SanjayGitHub00
Copy link

SanjayGitHub00 commented May 28, 2021

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
Copy link
Owner

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
Copy link

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
Copy link
Author

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants