我尝试使用 AngularJS $http.get 连接到以下 API。但是我无法构建正确的 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)
有人可以帮我正确地构建这个结构吗?谢谢
最佳答案
参数是搜索
而不是接收日期
return $http.get('https://api.fda.gov/drug/event.json', {
params: {
search: 'receivedate:' + val
}
关于javascript - 构建 $http.get 请求...错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28751398/