Multi-domain Search Module API Code Help

I need to implement a multi-domain search module for a client. As a result, I cloned the Hubspot search-input and search -results modules so that I could update the api url. However, I am not able to get search results with the changes. Can someone review my changes and let me know what I am doing wrong?

Search-input:

/*const SEARCH_URL_BASE = '/_hcms/v3/site-search/search';*/
const SEARCH_URL_BASE = '/contentsearch/v2/search';

Search-result:

/*var SEARCH_URL = '/_hcms/search?';*/
var SEARCH_URL = '/contentsearch/v2/search?';

Thanks in advance for the assistance.

Terry McMillan

Hi, @tmcmillan99 :waving_hand: Thanks for always bringing the interesting questions. Hey, @stefen @Indra @Anton, do you have any feedback you can share with @tmcmillan99?

From my end, I have a few questions and suggestions to give the community more details:

  • Have you tested the v2 Search endpoint in Postman? To verify you get an expected result, outside the module
    GET /contentsearch/v2/search​
  • Have you opened your browse’s dev console when making a request? To look for JS or other errors?

Consider adding a simple consloe.log() to your code. To help verify:

  • The search query is being captured correctly
  • The constructed URL is correct
  • The API call is successful and returns the expected results

Thank you. — Jaycee

Hey @Jaycee_Lewis

Thanks for the reply. I was actually able to resolve the issue yesterday and hadn’t had time to update my post with the solution. I successfully tested in Postman then looked at the console for errors. There was an error referencing the portal id. After some testing, the following url did the trick -
https://api.hubapi.com/contentsearch/v2/search?portalId=XXXXXXX&

I used it in both modules.

Thanks,

Terry

Thanks for letting us know. Have a great weekend! — Jaycee