Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lete114/body-data
一个轻量、小巧的Node.js模块,用于检索 GET 或 POST 请求数据 | A lightweight, small Node.js module for retrieving GET or POST request data
https://github.com/lete114/body-data
Last synced: 14 days ago
JSON representation
一个轻量、小巧的Node.js模块,用于检索 GET 或 POST 请求数据 | A lightweight, small Node.js module for retrieving GET or POST request data
- Host: GitHub
- URL: https://github.com/lete114/body-data
- Owner: Lete114
- License: mit
- Created: 2021-12-16T10:40:40.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-15T11:11:08.000Z (about 2 months ago)
- Last Synced: 2024-09-16T11:30:34.609Z (about 2 months ago)
- Language: JavaScript
- Homepage: https://body-data.vercel.app
- Size: 59.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Body-Data
一个轻量、小巧的Node.js模块,用于检索 GET 或 POST 请求数据
## 安装
```bash
npm install body-data --save
```## 快速开始
```js
// client
const script = document.createElement('script')
script.src = 'https://cdn.jsdelivr.net/npm/axios/dist/axios.js'
document.head.append(script)const url = 'http://127.0.0.1:6870'
axios.get(url, { params: { name: 'Lete', age: 18 } })
axios.post(url, { name: 'Lete', age: 18 })// server
const bodyData = require('body-data')
const http = require('http')const server = http.createServer(async (req, res) => {
res.setHeader('Content-Type', 'application/json; charset:utf-8;')
const data = await bodyData(req)
res.end(JSON.stringify(data)) // output: { name: 'Lete', age: 18 }
})server.listen(6870)
```