1. body-data
一个轻量、小巧的Node.js模块,用于检索 GET 或 POST 请求数据 | A lightweight, small Node.js module for retrieving GET or POST request data
body-data
Package: body-data
Created by: Lete114
Last modified: Fri, 07 Oct 2022 04:52:29 GMT
Version: 1.0.6
License: MIT
Downloads: 335
Repository: https://github.com/Lete114/Body-Data

Install

npm install body-data
yarn add body-data
语言: 中文 English

Body-Data

一个轻量、小巧的Node.js模块,用于检索 GET 或 POST 请求数据

Version dev MIT License

安装

 npm install body-data --save

快速开始

 // 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)

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin