GithubHelp home page GithubHelp logo

Comments (9)

asinorum avatar asinorum commented on July 17, 2024

I didnt have the exact same error , but maybe it helps, This what ended worked for me for some reason
const {data ={}} = useQuery(FETCH_POST_QUERY, { variables: { postId } })

Also replacing getPost for data.getPost in the rest of the code

from classsed-graphql-mern-apollo.

likwid23 avatar likwid23 commented on July 17, 2024

@asinorum That got rid of the error but now it gets stuck on Loading....

it never gets past the (!data.getPost)

from classsed-graphql-mern-apollo.

ArielPenna avatar ArielPenna commented on July 17, 2024

same to me,

from classsed-graphql-mern-apollo.

ArielPenna avatar ArielPenna commented on July 17, 2024

So annoying, i've tried everithing tha crossed mi mind, but it stills throw me the data undefined error

from classsed-graphql-mern-apollo.

mariusflorescu avatar mariusflorescu commented on July 17, 2024

Hello @ArielPenna 🚀, have you tried to do the following changes:

From:

const {data:{getPost}} = useQuery(FETCH_POST_QUERY,{
    variables: {
      postId
    }
  })

To:

const {data={}} = useQuery(FETCH_POST_QUERY,{
    variables: {
      postId
    }
  });
const thisPost = data.getPost;
  • change everywhere you see getPost to thisPost. (in the if statement and in the first instruction of the else).

Hope that helped you, let me know if it works!

from classsed-graphql-mern-apollo.

likwid23 avatar likwid23 commented on July 17, 2024

@mariusflorescu if I remove (!thisPost) I get:

TypeError: Cannot destructure property 'id' of 'thisPost' as it is undefined.

if (thisPost) {
25 | postMarkup =

Loading post..


26 | } else {

27 | const { id, body, createdAt, username, likes, likesCount, comments, commentCount} = thisPost;
| ^ 28 |
29 | postMarkup = (
30 |

Any ideas are appreciated

from classsed-graphql-mern-apollo.

ArielPenna avatar ArielPenna commented on July 17, 2024

Thanks @mariusflorescu this just work fine, i've tried it before I think, but didn't work.
Thanks a lot!!

from classsed-graphql-mern-apollo.

ArielPenna avatar ArielPenna commented on July 17, 2024

@likwid23 try like this, it's working for me

let postMarkup;
if (!thisPost) {
postMarkup =

Loading post..

;
} else {
const { id, body, createdAt, username, comments, likes, likeCount, commentCount } = thisPost;

from classsed-graphql-mern-apollo.

mariusflorescu avatar mariusflorescu commented on July 17, 2024

@ArielPenna I'm glad it worked.
You can mark the issue as closed 😁!

from classsed-graphql-mern-apollo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.