TypeError: Cannot read properties of undefined (reading 'undefined')

Hi!
Frontity rookie here. I developed this project last year and it has been working rather smoothly until yesterday or so. Itā€™s hosted on Vercel that says ā€œInternal Server Errorā€ and the function logs tell me ā€œError: TypeError: Cannot read property ā€˜undefinedā€™ of undefinedā€. Running it locally gives me ā€œTypeError: Cannot read properties of undefined (reading ā€˜undefinedā€™) at LandingPageā€ and I donā€™t really know where this is coming from.

My LandingPage looks like this:

import React from "react"
import { connect, styled } from "frontity"

const MainContainer = styled.main``

const LandingPage = ({ state, libraries }) => {
  const data = state.source.get(state.router.link)
  const page = state.source[data.type][data.id]
  const Html2React = libraries.html2react.Component

  return (
    <MainContainer>
      <Html2React html={page.content.rendered} />
    </MainContainer>
  )
}

export default connect(LandingPage)

and itā€™s being mounted in my TopMain (donā€™t blame me for the naming) like this:

const TopMain = ({ state }) => {
  const data = state.source.get(state.router.link)
  return (
    <>
      <Switch>
        {data.link === "/" ? (<LandingPage />)
          :
            (<>
              <Header />
              <Main />
              <Footer />
            </>)
        }
      </Switch>
    </>
  )
}

export default connect(TopMain)

When I log the

const data = state.source.get(state.router.link)

I get error 406, so does this mean the issue has to do with fetching from WordPress? Does anyone have a suggestion on how I start debugging this?

Links

System info

System:

  • OS: macOS 11.3
  • CPU: (8) x64 Intel(R) Coreā„¢ i5-8257U CPU @ 1.40GHz
  • Memory: 59.80 MB / 16.00 GB
  • Shell: 5.8 - /bin/zsh

Binaries:

  • Node: 16.14.2 - /usr/local/bin/node
  • npm: 8.5.0 - /usr/local/bin/npm

Browsers:

  • Chrome: 100.0.4896.127
  • Edge: 100.0.1185.50
  • Firefox: 99.0.1
  • Safari: 14.1

npmPackages:

  • @aamodtgroup/frontity-contact-form-7: git+https://github.com/HIPPIEKICK/frontity-contact-form-7.git => 0.2.6
  • @daily-co/daily-js: ^0.13.0 => 0.13.0
  • @frontity/core: ^1.13.0 => 1.15.1
  • @frontity/html2react: ^1.6.2 => 1.7.0
  • @frontity/tiny-router: ^1.4.2 => 1.4.4
  • @frontity/wp-source: ^1.11.4 => 1.11.7
  • @orballo/very-tiny-router: ^0.1.2 => 0.1.2
  • dayjs: ^1.10.4 => 1.10.4
  • frontity: 1.15.0 => 1.15.0 (1.17.2)
  • nkjt-theme: file:packages/nkjt-theme => 1.0.0
  • react-router-dom: ^5.2.0 => 5.2.0

npmGlobalPackages:

  • frontity: Not Found
  • npx: Not Found

Hi @matilda! Apparently this endpoint https://api.nkjt.se/wp-json/wp/v2/posts?_embed=true&slug=hem is returning empty, thatā€™s the reason the site is failing.

@orballo Hi there! Thank you for the answer. Iā€™m Matildaā€™s colleague, and Iā€™m wondering how I can fix this? That endpoint is indeed empty, and not used, so is there any way I can point it differently or to another endpoint? Where can I find these settings?

Thanks in advance!

@karinlinneanordkvist Sorry, I was out on a trip and couldnā€™t reply earlier. Iā€™m not sure what endpoint should be used to load that content. What endpoint is serving the data you need? Usually Frontity requests posts, and if nothing returned, pages, until it gets some content for the URL slug.

Thanks!

EDIT: Also, did you change something on Frontity or WP before it stopped working?