正在生成$http.get请求..错误

Building $http.get request...error

本文关键字:get 请求 错误 http      更新时间:2024-06-02

我有以下API,我正在尝试使用AngularJS$http.get连接到它。但是我无法构建正确的URL。

这是我想要使用的API URL

https://api.fda.gov/drug/event.json?search=receivedate:20040312

这是我的代码

return $http.get('https://api.fda.gov/drug/event.json?search=', {
  params: {
    receivedate: val
  }

但我的结果(错误)如下

GET https://api.fda.gov/drug/event.json?search=&receivedate=20040312 400 (Bad Request)

有人能帮我正确地构建它吗?感谢

参数是search而不是receivedate

return $http.get('https://api.fda.gov/drug/event.json', {
  params: {
    search: 'receivedate:' + val
  }