const express = require('express') const app = express() const port = 3000 const axios = require("axios"); app.all('*', function (req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Headers', 'Content-Type'); res.header('Access-Control-Allow-Methods', '*'); res.header('Content-Type', 'application/json;charset=utf-8'); next(); }); var Params = { url: 'http://v.juhe.cn/toutiao/index', key: 'c5e9594ee66a93b20c58b966e0490c73' } app.get('/index', (req, res) => { var type = req.query.type; axios.get(Params.url, { params: { type: type, key: Params.key } }) .then(function (response) { res.json(response.data) }) .catch(function (error) { console.log(error); }); }) app.listen(port, () => console.log(`Example app listening on port ${port}!`))