0

Using isomorphic fetch in react-redux to retrieve data from Django Rest Framework.

I'd like to send DRF a GET request with an array of PKs and get back their records.

From what I've read so far on StackOverflow, request bodies are not necessarily RESTful, it's too unwieldy to pass a large array in my url params, so I can only conclude that I need to do a POST or PUT request.

The bottom answer seems to be successful in sending a GET with a request.body, but I haven't been able to serialize the data

Request multiple ids from Django REST framework API

What's the best practice for retrieving data from DRF given some kind of user input?

TLDR:

  1. Do I initiate a GET (not RESTful, but it intuitively makes more sense)
  2. Do I POST? (update records showing that these records have been "viewed" and then serialize a response?)
  3. Something else?
Community
  • 1
  • 1
Anthony Chung
  • 1,367
  • 1
  • 16
  • 37
  • This answer should help inform your decision: http://stackoverflow.com/a/983458/1720161 – Kayra Apr 12 '16 at 19:57
  • Yup I read that. Since the GET doesn't follow the 1.1 spec and I POST, is that even restful? I'm attempting to search data. Therefore for large querysets, getting data is considered a POST? – Anthony Chung Apr 12 '16 at 20:00
  • From what I know, I'd say searching isn't enough to consider it a POST. If the request changes something, then it would be a POST. However if it is simply to retrieve data, even if work is done to retrieve that data, I would consider it a GET. – Kayra Apr 12 '16 at 20:10
  • makes sense: it'd be wise to consider it a GET. Thus in order to keep it restful, I'd send a large GET request in the url params? – Anthony Chung Apr 12 '16 at 20:12
  • As shown in the answer you linked, yes – Kayra Apr 12 '16 at 20:16

0 Answers0