privateer35 privateer35 - 8 months ago 31
Node.js Question

API calling with NPM module 'got'

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:


Is there anything wrong here?

enter image description here


Your promise handling is wrong.

You currently have:

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

When it should be:

...).then(resp => {