user1142130
user1142130

Reputation: 1645

Building $http.get request...error

I have the following API that I'm trying to connect to using AngularJS $http.get. However I can't build the correct URL.

This is the API URL I want to use

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

And this is the code I have

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

But my results (Error) are the following

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

Can someone help me structure this correctly? Thanks

Upvotes: 0

Views: 57

Answers (1)

Ronnie
Ronnie

Reputation: 11198

the param is search not receivedate

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

Upvotes: 2

Related Questions