/ts-router-post

Example of using Spin's TypeScript/Javascript Router to handle POST requests

Primary LanguageTypeScript

Spin TS Router Post Example

This is an example of getting POST data from the Spin implementation of Router.

Spin uses itt-router 3, but it is easier to use the Spin primitives to get the post body than it is to use itty-router middleware from within Spin. This shows how it is done.

The index.ts has all you need.

Using This Example

You will need Spin 2.0 or greater.

  • Clone this repo
  • Run npm install
  • Build and run the program with spin build --up

Now you can use a curl call to execute a test POST request:

$ curl -XPOST http://localhost:3000/example --data 'Hello World'
Hello World