Programmatically modifying a query | Scribe

    Programmatically modifying a query

    • Siddharth Kothari |
    • 0 step |
    • 23 seconds
    Navigate to your Search UI page
    Open "Code Editor"
    Open the app in Codesandbox
    Tip! Consider using this starter codesandbox link to follow the exact steps - [https://codesandbox.io/s/starter-modify-a-query-programmatically-y6i14x](https://codesandbox.io/s/starter-modify-a-query-programmatically-y6i14x)
    Navigate to [https://codesandbox.io/s/starter-modify-a-query-programmatically-y6i14x?file=/src/components/Search.js](https://codesandbox.io/s/starter-modify-a-query-programmatically-y6i14x?file=/src/components/Search.js)
    Navigate to "src > components > Search.js"
    Search for "<ReactiveBase />" component. We would be utilising transformRequest prop to append a queryString to the request.
    Read more about `transformRequest` prop here - [https://docs.reactivesearch.io/docs/reactivesearch/v3/overview/reactivebase/](https://docs.reactivesearch.io/docs/reactivesearch/v3/overview/reactivebase/)
    assign `transformRequest` prop to <ReactiveBase />
    We will assign a default search value("Batman returns") incase the user hasn't entered a query text in the SearchBox. Refer to the code snippet provided in the docs.
    We are almost done, let's confirm the changes to the query. Navigate to the app preview and open Networks tab in dev console.
    Notice the value key for the query with id='search' and type='search' in the payload.
    Awesome 👏🏻 , we did it! 😎 Starter Codesandbox link - [https://codesandbox.io/s/starter-modify-a-query-programmatically-y6i14x](https://codesandbox.io/s/starter-modify-a-query-programmatically-y6i14x) Final Sandbox link - [https://codesandbox.io/s/modify-a-query-programmatically-final-jf6u01](https://codesandbox.io/s/modify-a-query-programmatically-final-jf6u01)

    Want to make guides like this in seconds? Yes, it's really that fast.

    This Scribe is in tip-top shape!Leave feedback if there are any issues with this Scribe