Skip to content

Axios adds array indexes for objects in arrays where it shouldn't #5094

@doits

Description

@doits

Describe the bug

config.paramsSerializer.indexes = false (default) adds indexes if an object is inside an array but it shouldn't.

To Reproduce

https://runkit.com/doits/634530f2d3a446000813ef73

var axios = require("axios")

const req = await axios.get('https://www.example.com', { params: { a: [{ name: 'abc' }], b: ['x', 'y'] } })

console.log(req.request.path)

// => "/?a[0][name]=abc&b[]=x&b[]=y"

Expected behavior

No a[0] but a[]:

// => "/?a[][name]=abc&b[]=x&b[]=y"

Environment

  • Axios Version 1.1.2

Additional context/Screenshots

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions