Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在nodejs中使用不同的主机生成API_Node.js_Api - Fatal编程技术网

Node.js 在nodejs中使用不同的主机生成API

Node.js 在nodejs中使用不同的主机生成API,node.js,api,Node.js,Api,我是nodejs新手,目前正在使用localhost运行模拟api index.js- const express = require("express"); const api = require("./routes/api"); const app = express(); // Routes app.use("/api", api); // route api routes/api/index.js- const router = express.Router(); router.g

我是nodejs新手,目前正在使用
localhost
运行模拟api

index.js-

const express = require("express");
const api = require("./routes/api");
const app = express();

// Routes
app.use("/api", api); // route api
routes/api/index.js-

const router = express.Router();

router.get("/path-to-certain-resource", async (req, res) => {
 });
//...
router.post("/path-to-another-resource", async(req,res) => {
});
我需要使用预定义的url创建一个新的API- e、 g.
https://example.com/api/v1/users


我如何才能做到这一点?

使用Heroku cloud,阅读相关教程。(搜索如何在heroku上部署nodejs服务器。)使用heroku云,阅读相关教程。(搜索如何在heroku上部署nodejs服务器。)