Saturday 27 April 2019

Need help with a beginners issue

Hello,I can’t get the contentful connection up and running and this is what I have:I have a node script that makes the connection to contentful named connectcontentful.js in the data folder with this code:import * as contentful from 'contentful' const SPACE_ID = '123456' const ACCESS_TOKEN = 'ABCGDEFG' const contentclient = contentful.createClient({ space: SPACE_ID, accessToken: ACCESS_TOKEN }) export default contentclient Then I want to load that into my app.js with this code:var cc = require('./data/connectcontentful'); cc.contentclient.getEntry('3dImb5wbU7dD1qdllUgBY6') .then(function (entry) { // logs the entry metadata console.log(entry.sys) // logs all fields console.log(entry.fields) // logs the field with ID image console.log(entry.fields.image) }) When I run app.js I get this error:​×TypeError: Cannot read property 'getEntry' of undefined./src/App.jssrc/App.js:3 1 | var cc = require('./data/connectcontentful'); 2 |3 | cc.contentclient.getEntry('3dImb5wbU7dD1qdllUgBY6') 4 | .then(function (entry) { 5 | // logs the entry metadata 6 | console.log(entry.sys)View compiled__webpack_require__/Users/timloenders/Dropbox/co-own.it/app2/webpack/bootstrap:781 778 | }; 779 | 780 | // Execute the module function781 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); | ^ 782 | 783 | // Flag the module as loaded 784 | module.l = true;View compiledfn/Users/timloenders/Dropbox/co-own.it/app2/webpack/bootstrap:149 146 | ); 147 | hotCurrentParents = []; 148 | }149 | return webpack_require(request); | ^ 150 | }; 151 | var ObjectFactory = function ObjectFactory(name) { 152 | return {View compiledModule../src/index.jshttp://localhost:3000/static/js/main.chunk.js:129:62__webpack_require__/Users/timloenders/Dropbox/co-own.it/app2/webpack/bootstrap:781 778 | }; 779 | 780 | // Execute the module function781 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); | ^ 782 | 783 | // Flag the module as loaded 784 | module.l = true;View compiledfn/Users/timloenders/Dropbox/co-own.it/app2/webpack/bootstrap:149 146 | ); 147 | hotCurrentParents = []; 148 | }149 | return webpack_require(request); | ^ 150 | }; 151 | var ObjectFactory = function ObjectFactory(name) { 152 | return {View compiled0http://localhost:3000/static/js/main.chunk.js:257:18__webpack_require__/Users/timloenders/Dropbox/co-own.it/app2/webpack/bootstrap:781 778 | }; 779 | 780 | // Execute the module function781 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); | ^ 782 | 783 | // Flag the module as loaded 784 | module.l = true;View compiledcheckDeferredModules/Users/timloenders/Dropbox/co-own.it/app2/webpack/bootstrap:45 42 | } 43 | if(fulfilled) { 44 | deferredModules.splice(i--, 1);45 | result = webpack_require(webpack_require.s = deferredModule[0]); | ^ 46 | } 47 | } 48 | return result;View compiledArray.webpackJsonpCallback [as push]/Users/timloenders/Dropbox/co-own.it/app2/webpack/bootstrap:32 29 | deferredModules.push.apply(deferredModules, executeModules || []); 30 | 31 | // run deferred modules when all chunks ready32 | return checkDeferredModules(); | ^ 33 | }; 34 | function checkDeferredModules() { 35 | var result;View compiled(anonymous function)http://localhost:3000/static/js/main.chunk.js:1:57This screen is visible only in development. It will not appear if the app crashes in production.Open your browser’s developer console to further inspect this error.------​So probably I skip a step or something. Anyhow in Atom the “const contentclient” doesn’t color the contenclient orange like it should do with a const I would say.Sorry to bother with this beginners stuff, but I can’t get through this one.Thanks for any help!Tim

Submitted April 27, 2019 at 08:17PM by tlow001

No comments:

Post a Comment