HTTP Request using rescript-nodejs

Are there examples using rescript-nodejs for the GET/POST requests using the HTTP module of Node.js? I wanted to perform a GET request for a service running on my localhost from an express.js (rescript-express) route handler:

app->get("/api/items/:id/itemDetail.json", (req, res) => {
  open NodeJs
  let params = req->params
  let itemId = params["id"]
  let url = "http://localhost:8000" ++ "/api/items/"++itemId ++"/itemDetail.json"
  let request = Http.get(url)
  let _ = res->status(200)

How do I stick the data and end events into the callback from this example here. I do know that I need to use the Http.getWithCallback binding, but I don’t know how. Any hints?

I recommend using Undici for making requests in nodejs. It’s a faster HTTP/1.1 client with a modern API maintained by nodejs organisation.

Here are some examples:

There’s also of course node-fetch, which will work regardless of Node version as it’s a third-party package.