我正在使用AngularJS $ http.get尝试连接以下API。但是我无法构建正确的URL。
这是我想要使用的API网址
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)
有人可以帮我正确构建吗?感谢
答案 0 :(得分:2)
该参数为search
而非receivedate
return $http.get('https://api.fda.gov/drug/event.json', {
params: {
search: 'receivedate:' + val
}