Hi,
I’m trying to pull pages/posts from two different WP API. I tried adding a second source in the frontity.settings.js file, but that didn’t seem to affect anything. I also tried just using the native js fetch request on the second site, and that gives me a reference error where fetch is not defined. All of the multisite posts are about serving frontity to two different existing domains, feels like I’m trying to do the opposite. Essentially, I want to have one component on my site that uses the data from a different set of posts (i.e. separate wp json data) than the rest of my content. Any help would be appreciated.
Update: Going back through the docs I made some further progress. Using the multisite information here I adjusted my frontity.settings.js. Just as a note, it seemed I had to make my match settings into an array
{
"name": "abc",
match: ["(?!\/events-calendar)"],
...
},
"packages": [
{
"name": "abc-theme",
},
{
"name": "@frontity/wp-source",
"state": {
"source": {
"url": "https://source1.com",
}
}
},
"@frontity/tiny-router",
"@frontity/html2react"
]
},
{
"name": "abc-events",
match: ["\/events-calendar"],
...
},
"packages": [
{
"name": "abc-theme",
},
{
"name": "@frontity/wp-source",
"state": {
"source": {
"url": "https://source2.com",
}
}
},
"@frontity/tiny-router",
"@frontity/html2react"
]
}
Then following some of the advice form this post by @luisherranz I tried adding a useEffect hook to the component I want to fetch from the second site, using the /events-calendar path
React.useEffect(() => {
actions.source.fetch("/events-calendar")
}, [ ])
const data = state.source.get("/events-calendar")
However, now when I try to log “data” in order to see how I can map the items, I am receiving a 404 error.
Maybe this was the wrong way to go, still open to any help possible.
Thanks,
Gideon