[如何通过更改URL中的参数从API更改数据? javascript上的Restfull API?

问题描述 投票:0回答:1

我设置了一个斜线端点。

我想在用户输入时输入:http / website.com / date = 2019-08-01-station = 41027-daysForward = 5

能够更改三个参数以获得不同的数据。

date =“第一个参数”

station =“第二参数”

daysForward =“第三参数”

con.connect(function(err) {
    if (err) throw err;
    //Select all customers and return the result object:
    con.query("CALL aladin_surfex.Get_mod_cell_values_meteogram('2018-08-01',41027,5)", function (err, result, fields) {
      if (err) throw err;
      console.log(result);
      aladinModel = result;
    });
});
// Root endpoint
app.get("/", (req, res, next) => {
    res.json({aladinModel})
});
app.use(function(req, res){1
    res.status(404);
});

如何使用空字符串制作变量并在请求位置替换它们?

javascript api restful-url
1个回答
0
投票

您应改用query parameters

http / website.com?date = 2019-08-01&station = 41027&daysForward = 5

© www.soinside.com 2019 - 2024. All rights reserved.