node-express如何在URL查询字符串中传递DATE参数,以及如何解析该参数 [英] node-express how to pass DATE params in URL query string and how to parse that
本文介绍了node-express如何在URL查询字符串中传递DATE参数,以及如何解析该参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个基于angular 2的应用程序,该服务的功能是发送http请求以从oracle DB,usind node-oracle db和express框架中获取数据. 我已经使用express构建了rest api,现在我需要在请求参数中传递DATE,而express必须对其进行解析并发送响应.我如何在查询参数中传递DATE以及如何在Express Rest API中解析它.
I have an app built on angular 2, a service in that sending http request to fetch the data from oracle DB, usind node-oracle db and express framework. I have built rest api's using express, now i need to pass the DATE in request parameter and express has to parse that and send the response. How can i pass the DATE in query param and how i can parse that in express rest api.
推荐答案
以iso格式'yyyy-mm-dd'传递日期
pass the date with iso format 'yyyy-mm-dd'
const date = new Date();
http.get(`url/test?date=${date.toISOString()}`
在快递方
app.get(/test', async function(req, res) {
const dateInServer = newDate(req.query.date);
});
这篇关于node-express如何在URL查询字符串中传递DATE参数,以及如何解析该参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文