Multiple fields with same key in query params (axios request)?

前端 未结 5 1973
甜味超标
甜味超标 2020-12-05 04:27

So the backend (not under my control) requires a query string like this:

http://example.com/?foo=5&foo=2&foo=11

But axios

5条回答
  •  离开以前
    2020-12-05 04:54

    Adding more details to @nhydock accepted answer. When you do

    var request = {foo: [5, 2, 11] }
    

    axios.get('http://example.com/', request);

    For django application you can receive these as

    self.request.query_params.getlist('foo')
    

    also.

提交回复
热议问题