The urlToSearchRequest() method allows designers to transform a search URL into a JSON search request.
Example
It can be useful to get the current search page URL, and to convert it to a search request usable in the Create a search web service.
For example:
const currentUrl = window.location.href;
const search_request = FluidTopicsUrlService.urlToSearchRequest(currentUrl);
// Construct the JSON body using the captured input values
const requestBody = {
title: "Default title",
description: "Default description",
color: "red",
alert: true,
searchRequest: search_request
};
// Define the API endpoint using the predefined user profile ID
const apiEndpoint = `/api/users/${user.profile.id}/searches`;
// Initialize the FluidTopics API client
const FTAPI = new window.fluidtopics.FluidTopicsApi();
// Make the POST request with the request body
const response = await FTAPI.post(apiEndpoint, requestBody);