Delivery API upgrade 0.9 to 1.0: Wrong PageModel used?

Hello,

I’m trying to upgrade the delivery API from 0.9 to 1.0.
I’m using react on the frontend and BloomreachXM 14.7.

I am currently using “bloomreach/react-sdk”: “18.0.1” and it has “@bloomreach/spa-sdk”: “18.0.1” as a transitive dependency.

After updating the default pagemodelapi version to 1.0 in hst-config.properties I’m able to see the new API response format when I call for /resourceapi/ , but I’m also seeing errors in the devtools console:

Uncaught Error: Unsupported component type: ‘undefined’.
at ComponentFactory.buildComponent (component-factory09.ts:68:1)
at ComponentFactory.create (component-factory09.ts:55:1)
at new PageImpl (page09.ts:84:1)

These errors are happening in files coming from @bloomreach/spa-sdk package.

After looking through the code from the package the issue seems to be related to the component types being changed in the API response between the two API versions from uppercase format ‘CONTAINER_ITEM_COMPONENT’ to lowercase ‘container-item’.

I can see the difference when I compare the delivery api response:
0.9: “type”: “CONTAINER_COMPONENT”,
1.0: “type”: “container”,

I think somehow the wrong files are being used as I see component09.ts, component-factory09.ts being hit when it should be component.ts, component-factory.ts as those have the correct type casing.

I think the issue may also be related to page-factory.ts where I see this line:
export type PageFactory = Builder<[PageModel | PageModel09], Page>;

Is the Delivery API 1.0 compatible with my sdk version? Is there a configuration I’m not setting up properly?

Thank you!

Hi Jonathan,

These articles should be able to help you, please check:

Thanks!

Hello Richa,

Thanks for the response!

I’ve looked through the documentation you mentioned but I don’t believe I see an answer to the problem I’m facing. I believe I have already gotten the delivery API configured to 1.0 according to that documentation as I’m able to see a json response in the 1.0 format.

I’ve updated my original post to hopefully clarify a bit more on my issue.

Thanks

Hi @Jonathan_Li,
Unsupported component type “undefined” error would indicate your component mapping between HST and SPA cannot be resolved. Can you please check how you configured your components in HST (do they have proper names/labels?)
Please check this document for reference.

Also, removing cType and component label produces “Component “undefined” is not defined.” error (it is just an output error, not JS error).

Hello Hema,

Thanks for your response!

I took a look at the document link you sent and I believe I have already configured the resource api in the HST properly just as the instructions show. We had already set it up and it was working for Delivery API version 0.9, but after updating the version to 1.0 I came across the undefined issue.

We do have the labels for our components set up as well in the console.

Thanks