Fetch WP data from a non Wordpress endpoint

Hi All,

Is it possible to fetch data formatted as REST api output but from a non-Wordpress endpoint? I have created my own caching endpoint which fetches Wordpress data and caches it. I’d like to fetch the cached data.

I presume Frontity does some sort of check?

Thanks

Hi @mike1, you can fetch any non-WordPress data like below

const response = await libraries.source.api.get({
       endpoint: `/yarpp/v1/related/` + postID + `/`,
 });

const relatedPostData = await response.json()

And after that, you have stored this result to state using actions. And you can use that state in the whole frontity site anywhere you want.

Thanks for the reply Santosh.

It’s more of a curiosity question.

If I say stored the Rest API ‘posts’ call somewhere could I fetch it configured here:

        "name": "@frontity/wp-source",
        "state": {
            "source": {
                "url": "https://get.mylocal.version"

Hi Santosh,

Thanks for this reply. I’m getting to understand what is going on.

Can you set the value for ‘libraries.source.api’?

Regards