Skip to content

Instantly share code, notes, and snippets.

@codebutler
Created March 23, 2023 20:49
Show Gist options
  • Save codebutler/4fa8f6ff7c9cb51d5be7e4345054cbf1 to your computer and use it in GitHub Desktop.
Save codebutler/4fa8f6ff7c9cb51d5be7e4345054cbf1 to your computer and use it in GitHub Desktop.
String array query parameters with axios + django-rest-framework
const api = axios.create({
// other options...
paramsSerializer: {
// drf expects array params to be repeated, e.g. ?foo=bar&foo=baz
// the default behavior is to serialize them as foo[]=bar&foo[]=baz
serialize: (params) => qs.stringify(params, { arrayFormat: "repeat" }),
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment