Calling libraries.source.populate() without an id property

I’m using a custom handler to fetch a list of WordPress options from my server

    const response = await libraries.source.api.get({
      endpoint: `/acf/v3/options/options`,
    });

    const [options] = await libraries.source.populate({
      response,
      state,
      force,
    });

    Object.assign(state.source.data[link], options);

source.populate is throwing an error because ID is undefined. Since this is just a collection of key/value site options there is no ID field. I would like to use populate since it’s the official API and I think will cache the values.

I can get it to work by just getting the key from source and setting the data, but the data is reloaded every page change vs being cached after the first page load.

Any ideas on how to use source.populate without an ID field?

Hi @john

Welcome to the Frontity community.

populate will normally work with post types, whether posts, pages, or CPTs. It’s not really designed to work with arbitrary content, such as option like you’re getting.

Once you have the response data you could store it in the state anywhere that you deem appropriate, without necessarily using populate.