【问题标题】:getProductById from firebase using query params使用查询参数从 Firebase 获取产品ById
【发布时间】:2020-09-11 08:26:00
【问题描述】:

我试图在单击 NativeScript 应用程序项时动态获取产品。我目前正在使用 firebase,对它并不熟悉。

方法如下

  getDish(id: number): Observable<Dish> {
    return this.http.get<Dish>(baseURL +'dishes.json/'+ id)
      .pipe(catchError(this.processHTTPMsgService.handleError));
  }

这里是 firebase 目标“[firebaseName]firebaseio.com/disshes/0”[1/2/3/4 等]。

我做错了什么?

如果您有特定的更正或链接 高度赞赏。

【问题讨论】:

  • 结果:错误:TypeError:无法读取未定义的属性“0”

标签: javascript typescript firebase firebase-realtime-database nativescript


【解决方案1】:

.json 后缀需要放在 URL 的最后:

return this.http.get<Dish>(baseURL +'dishes/'+ id + '.json')

【讨论】:

  • 男人!您两次挽救了初学者的一天。谢谢弗兰克。你太慷慨了。
猜你喜欢
  • 2021-01-15
  • 1970-01-01
  • 2018-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-09
  • 1970-01-01
相关资源
最近更新 更多