原文链接: express 和 axios 使用post传递 json 格式的参数
上一篇: node 使用 concurrently 启动多个监听服务
server
跨域安装
npm i cors -D
var express = require('express')
var app = express()
var bodyParser = require('body-parser');//解析,用req.body获取post参数
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
const fs = require('fs')
const cors = require('cors');
const path = require('path')
app.use(cors());
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function (req, res) {
res.send('hello world'