<p>This shows one technique for handling POST data using the <code>Router</code> object <a href="https://developer.fermyon.com/spin/v2/javascript-components">built into the JS/TS SDK</a> for Spin.</p> <p>This example illustrates how to pass the HTTP body from Spin’s SDK all the way to your end function without needing to use middleware.</p> <pre><code class="language-typescript">export const handleRequest: HandleRequest = async function (request: HttpRequest): Promise&lt;HttpResponse&gt; { let router = Router() // This gets the base path from the request, which is considered better // than hardcoding it. Now, when the `route` is changed in spin.toml, // our code does not need to change. let basePath = request.headers[&quot;spin-component-route&quot;] // Note that we pass `request.body` as the second param. // That contains an ArrayBuffer with the encoded body. router.post(basePath, (req, body) =&gt; { // Decode the ArrayBuffer into a string let decodedBody = decoder.decode(body) return { status: 200, headers: { &quot;content-type&quot;: &quot;text/plain&quot; }, body: decodedBody } }) // IMPORTANT: We pass the request body as the second param. return await router.handleRequest(request, request.body) } </code></pre> <p>Check out the GitHub repository for a full runnable example.</p>