Cloudflare worker
Cloudflare Workers provides a serverless execution environment that allows you to create entirely new applications or augment existing ones without configuring or maintaining infrastructure.
Documentation for Cloudflare worker.
Cloudflare-worker-request-data
Getting data from Cloudflare-worker requests is not as easy as you were working with Express.js on Nodejs, it is necessary to understand the organization of request
in Cloudflare-worker.
Cloudflare-worker-request-data is a JavaScript package released under MIT license, which can help you with getting data from a GET
or POST
request. With this package, it is not necessary to study the API of request
from documentation file, and the usage is quite simple and straightforward.
Installation
1 | npm i cloudflare-worker-request-data |
Example
1 | import { RequestData } from 'cloudflare-worker-request-data'; |
Description
RequestData(request)
in the above example can get return of
- a
String
in case of “application/text” or “text/html” - a
Object
in case of “application/json”, “application/x-www-form-urlencoded”, “mutipart/form-data” - a
String
which is empty if nothing parsed - The request shall be either in
GET
orPOST
, other methods of request will directly return you with an emptyString
.