首页 \ 问答 \ 格式Twitter API Date在node.js后端使用moment.js(Format Twitter API Date uses moment.js on node.js backend)

格式Twitter API Date在node.js后端使用moment.js(Format Twitter API Date uses moment.js on node.js backend)

我目前正在尝试格式化Twitter API日期但是我不确定如何访问它并在快速路由器中重新发送它作为数据然后在Jade文件中使用。

router.get('/', (req, res, next) => {
  client.get('statuses/user_timeline', params, function (error, tweets, response) {
    Promise.all([
      getArticles(),
      getInstas()
    ])
      .then(data => res.render('pages/news-centre/home', {
        articles: data[0].slice(0, 4),
        tweets: tweets,
        instagram: data[1].data
      }))
    .catch(next)
  })
})

我正在使用来自npm的Twitter API客户端 。 我从utilitys.js文件中的utilitys.js获取我的instagram和文章json数据。

我可以通过#{tweets[i].created_at}使用jade访问twitter日期,但是我想在我之前使用moment.js格式化它们。

如果有人能指出我正确的方向我会有点迷失,那将会很棒。


I'm currently trying to format the Twitter API Date however I'm unsure how to access it and resend it within the express router as data to then use in a Jade file.

router.get('/', (req, res, next) => {
  client.get('statuses/user_timeline', params, function (error, tweets, response) {
    Promise.all([
      getArticles(),
      getInstas()
    ])
      .then(data => res.render('pages/news-centre/home', {
        articles: data[0].slice(0, 4),
        tweets: tweets,
        instagram: data[1].data
      }))
    .catch(next)
  })
})

I am using the Twitter API Client from npm. I'm getting my instagram and article json data from promises in a utilitys.js file.

I can access the twitter date using jade via #{tweets[i].created_at} however I'd like to format them using moment.js before I do.

Would be great if someone could point me in the correct direction I'm a little lost.


原文:https://stackoverflow.com/questions/36481994
更新时间:2022-08-08 17:08

最满意答案

在该上下文中, double a[]double *a被定义为绝对的,100%相同。 这是一个C ++问题,但C FAQ仍然是相关的。


从C ++ 11标准:

8.3.5

在确定每个参数的类型之后,将“T数组”或“函数返回T” 类型的任何参数分别调整为“指向T的指针”或“指向函数返回T的指针”。


In that context double a[] and double *a are defined to be absolutely, 100% identical. This is a C++ question but a C FAQ is still relevant.


From the C++11 standard:

8.3.5

After determining the type of each parameter, any parameter of type "array of T" or "function returning T" is adjusted to be "pointer to T" or "pointer to function returning T," respectively.

相关问答

更多
  • c和d在技术上是两个不同的对象, ==运算符仅比较引用。 c.equals(d) 因为它比较值而不是参考。 但仍然不理想。 直接比较浮点值应该总是考虑一些误差(ε)( Math.abs(c - d) < epsilon )。 注意: Integer c = 1; Integer d = 1; 这里比较会产生true ,但这更复杂( Integer内部缓存,在Integer.valueOf() JavaDoc中描述): 此方法将始终缓存-128至127(含)范围内的值,并可缓存此范围之外的其他值。 为什么 ...
  • 道格拉斯的答案对JIT优化死码是正确的(x86和x64编译器都会这样做)。 但是,如果JIT编译器正在优化死代码,那么立即显而易见,因为x不会出现在本地窗口中。 此外,手表和即时窗口会在尝试访问它时给出错误:“当前上下文中不存在名称”x“。 这不是你所描述的那样的事情。 您看到的是Visual Studio 2010中的一个错误。 首先,我试图在我的主机上复制这个问题:Win7x64和VS2012。 对于.NET 4.0目标,当关闭大括号时, x等于3.0D。 我决定尝试.NET 3.5目标,并且, x也被 ...
  • 如果您希望在用户拨打没有参数的呼叫时执行某个功能,请为您的参数指定一个默认值: void foo(double d = 0.0) { ... } void foo(int i) { ... } void foo(char c) { ... } 当用户调用foo() ,将调用double的重载。 代码将被执行,就像传递了零一样。 If you want a function to execute when users make a call with no parameters, g ...
  • 在该上下文中, double a[]和double *a被定义为绝对的,100%相同。 这是一个C ++问题,但C FAQ仍然是相关的。 从C ++ 11标准: 8.3.5 在确定每个参数的类型之后,将“T数组”或“函数返回T” 类型的任何参数分别调整为“指向T的指针”或“指向函数返回T的指针”。 In that context double a[] and double *a are defined to be absolutely, 100% identical. This is a C++ quest ...
  • Primo,double(* test)(double)是类型名称,如int或float。 所以你需要声明double(* test)(double)foo,其中foo是变量名(如int n)。 Sceundo,类型的名称不能是函数的名称。 函数指针需要返回tupe,args类型和非保留名称。 所以试试double(* custom_name)(double)。 Tertio,主函数中没有tarpez(a,b,n,test(x))。 使用tarpez(a,b,n,test); 你只能在这个空间使用名字。 P ...
  • double是C ++关键字,而DOUBLE是实现定义的typedef。 例如,如果我在MS VC ++中的项目中包含 ,那么IDE会显示在WTypesbase.h定义了DOUBLE ,如: typedef double DOUBLE; double is a C++ keyword while DOUBLE is implementation defined typedef. For example if I will include in a projec ...
  • void pcmTocomplex(short *data, double *outm[2]) 你在这个函数原型中看到的第二个参数意味着双指针数组,而不是你想要的。 void pcmTocomplex(short *data, double (*outm)[2]) 这个如果你想要它应该是什么样子,你期望什么。 void pcmTocomplex(short *data, double *outm[2]) This second parameter , you seen in this function ...
  • 其实我相信BOTH功能都失败了。 你只是没有注意到C-to-F失败了,因为你得到了非零结果。 在C ++中,除法的结果类型取决于操作数的类型,而不是最准确地表示结果的类型。 换句话说,5/9是整数除法 ,并且将被截断为0.如果你使用类似5.0 / 9.0的东西,它将把数学作为双精度,并且很可能给你一个你想要的结果。 但是,如果你满足于截断结果,你可以重新排列这些术语,使其尽可能晚地进行舍入: double C = ((F - 32) * 5 / 9); Actually I believe BOTH fun ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)