小编Ben*_*GHT的帖子

Mongoose '.inlcudes' - 'ObjectId' 类型的参数不可分配给 '{ type: ObjectId; 类型的参数;必需:真实;}'

我正在将 JS 节点/express 和 mongoose 服务器转换为 Typescript,并且我对 mongoose 的数组包含 typescript 的方法有疑问:

Argument of type 'ObjectId' is not assignable to parameter of type '{ type: ObjectId; required: true; }'.
  Type 'ObjectId' is missing the following properties from type '{ type: ObjectId; required: true; }': type, required

78     if (!building.actors.includes(mongoose.Types.ObjectId(userID)))
Run Code Online (Sandbox Code Playgroud)

导致此问题的行如下:

const transformedUserID = mongoose.Types.ObjectId(userID)
if (transformedUserID && !building.actors.includes(transformedUserID)) {
   ...
Run Code Online (Sandbox Code Playgroud)

该错误表明缺少所需的属性,因此我认为这可能是涉及 userID 可能为空的问题,所以我尝试了此操作但没有成功:

transformedUserID || mongoose.Types.ObjectId()
Run Code Online (Sandbox Code Playgroud)

我是 Typescript 的新手,所以不太确定为什么会发生这种情况,它在普通 JS 中工作得很好。任何帮助,将不胜感激。

谢谢

mongoose node.js typescript

4
推荐指数
1
解决办法
4437
查看次数

使用Graph API访问私人facebook组的帖子

我一直在尝试(收效甚微)一段时间来获取我所在的私人团体的所有帖子,并将其显示在我们的网站上,以便Facebook上的人仍可以看到他们.我知道这可能是一个公共团体(我们的团队不可能),但是有可能与私人团体合作吗?

我已尝试在Graph API Explorer上访问令牌,但这只是返回:

{
  "data": [
  ]
}
Run Code Online (Sandbox Code Playgroud)

我还读到,要访问用户需要以该组中的用户身份登录的私有组.然而,这是毫无意义的,因为尝试这样做的重点是允许没有facebook的人看到该组的帖子.

谢谢你们

facebook facebook-graph-api

2
推荐指数
1
解决办法
3829
查看次数