2

I've set up a component in ReactJS that makes an API call to GhostJS's API for displaying posts but I receive the error:

HomePage.js:30 Uncaught (in promise) TypeError: Cannot read property 'body' of undefined(…)

Below is the example component. Am I supposed to refer directly to Ghost's API or the API within my own site? Ghost's documentation for their API doesn't explain this part very well.

Besides calling their API, I've tried calling my sites API by replacing the root URL to this output:

got(`http://localhost:2368/posts/${postId}`)...

Is there anything wrong here?

enter image description here

privateer35
  • 365
  • 2
  • 6
  • 14

1 Answers1

1

Your promise handling is wrong.

You currently have:

...).then(resp, () => {
    ...
});

When it should be:

...).then(resp => {
    ...
});
m_callens
  • 6,100
  • 8
  • 32
  • 54