The window.fluidtopics.FluidTopicsApi() method allows designers to use the Fluid Topics API in Custom components more easily.
The following example uses the GET method.
It calls the List bookmarks web service for the current user, and prints its response in the browser console:
FTAPI = await new window.fluidtopics.FluidTopicsApi();
FTAPI["Ft-Calling-App"] = "ft-page-designer";
bookmarks = await FTAPI.get(`/api/users/${user.profile.id}/bookmarks`);
console.log(bookmarks);
The following example uses the POST method.
It calls the Search maps web service, asking for maps matching the word "API" and in American English. Then, it prints its response in the browser console:
FTAPI = await new window.fluidtopics.FluidTopicsApi();
FTAPI["Ft-Calling-App"] = "ft-page-designer";
body = {
"query": "API",
"contentLocale": "en-US"
}
api_maps = await FTAPI.post(`/api/khub/maps/search`, body);
console.log(api_maps);
- Always include a
Ft-Calling-Appheader for accurate API calls calculation. - For a more complete example, see User bookmarks example.
- The code for Custom components is public. Do not add credentials in a Custom component.
- Fluid Topics user roles limit the web services which a user can call. For more information, see Fluid Topics API Reference Guide.