kitajchuk / node-squarespace-server

DEPRECATED! A local Squarespace development server in node.js.
MIT License
186 stars 26 forks source link

TypeError: Cannot read property 'links' of null #158

Closed blakeswitchco closed 8 years ago

blakeswitchco commented 8 years ago

After upgrading I am seeing the following issue when starting up the server.

$ sqs buster sqs-log Clear local cache $ sqs server sqs-log Issue compiling less file global.less => 'social-icon-font.less' wasn't found sqs-log Issue compiling less file mobile.less => 'sqs-grid-breaker.less' wasn't found sqs-log Squarespace server running localhost:5050 sqs-log Logging into Squarespace... sqs-log ...Logged in to Squarespace sqs-log Fetching data from Squarespace... sqs-log Fetched fullData for collection 55ee9576e4b0ce8ff0dab529 ... sqs-log Fetched fullData for collection 56517021e4b037d305ddeeb5 sqs-log ...Fetched data from Squarespace sqs-log Get local cache for key => page-homepage.html sqs-log Get local cache for key => page-homepage.json sqs-log Store local cache for key => page-homepage.json sqs-log Store local cache for key => page-homepage.html sqs-log Get local cache for key => page-homepage.html /usr/local/lib/node_modules/node-squarespace-server/squarespace-template.js:1120 xt = getNavigationContextItems( navigation, (pageLinks || navigation.links), p ^ TypeError: Cannot read property 'links' of null at getNavigationContext (/usr/local/lib/node_modules/node-squarespace-server/squarespace-template.js:1120:85) at replaceNavigations (/usr/local/lib/node_modules/node-squarespace-server/squarespace-template.js:1006:23) at Object.renderTemplate (/usr/local/lib/node_modules/node-squarespace-server/squarespace-template.js:516:16) at /usr/local/lib/node_modules/node-squarespace-server/squarespace-server.js:263:29 at /usr/local/lib/node_modules/node-squarespace-server/node_modules/node-squarespace-middleware/squarespace-middleware.js:376:13 at Request._callback (/usr/local/lib/node_modules/node-squarespace-server/node_modules/node-squarespace-middleware/squarespace-middleware.js:299:9) at Request.self.callback (/usr/local/lib/node_modules/node-squarespace-server/node_modules/request/request.js:198:22) at Request.emit (events.js:110:17) at Request. (/usr/local/lib/node_modules/node-squarespace-server/node_modules/request/request.js:1035:10) at Request.emit (events.js:129:20)

The startup creates two empty files in sqs-cache, page-homepage.html and page-homepage.json which need to be busted otherwise an unexpected input error is kicked back.

Not too sure what I should do to address this, everything I've tried is coming up fruitless (commenting out nav sections in the templates/removing links on the prod site/busting busting busting). I am using the Wexley template and have sqs-server/middleware/logger/jsont updated to the latest versions. I am praying there's something I am missing with the update or a simple fix to get this back into action.

Thanks so much!

kitajchuk commented 8 years ago

It appears the navigation the server is attempting to find from the API JSON is null. It looks like the most likely reason this would happen is if a navigation with the ID specified in the template tag is not found within your sites layout API data. The layout API data can be referenced by hitting this path off of your Squarespace site's domain: /api/commondata/GetSiteLayout/.

blakeswitchco commented 8 years ago

Thanks! You are 100% correct, had a secondary nav block kicking around in the mobile nav that was cut from the site.