Connect the application to MarkLogic
After installing FastTrack, connect the application to MarkLogic by wrapping the application with the MarkLogicProvider
widget and add props for the middle-tier server. MarkLogicProvider
provides access to MarkLogicContext
, which exposes methods for calling MarkLogic’s REST endpoints. Replace the code in the main.jsx
file with this:
import React from 'react' import ReactDOM from 'react-dom/client' import App from './App.jsx' import { MarkLogicProvider } from "ml-fasttrack" ReactDOM.createRoot(document.getElementById('root')).render( <MarkLogicProvider scheme="http" host="localhost" port="4001" options="search-options" auth={{ username: "fasttrack-getting-started-user", password: "password" }} > <App /> </MarkLogicProvider>
Note
This application passes a user name and password with each request. The middle tier passes that information to MarkLogic. In a real-world application, authentication would commonly be handled in the middle tier.