crazyfrog
crazyfrog

Reputation: 247

Axios object as params not readable by backend

I have a problem with my axios query:

apiClient.get('http://localhost:8080/api/internalLocations/search', {
      params: {
        locationTypeCode: 'BIN_LOCATION',
        offset: '0',
        max: '5',
        parentLocation: {
          id: `${this.props.currentLocation}`,
        },
      },
    })

The query needs to be typeof ?[...]offset=5&parentLocation.id=xyz, but now it is like this: &offset=0&max=5&parentLocation={"id":"[object Object]"} and the backend doesn't know how to handle that. Is there any possibility to make it parentLocation.id=xyz?

Upvotes: 0

Views: 76

Answers (1)

Slawa Eremin
Slawa Eremin

Reputation: 5415

Try this, it should work

apiClient.get('http://localhost:8080/api/internalLocations/search', {
      params: {
        locationTypeCode: 'BIN_LOCATION',
        offset: '0',
        max: '5',
        'parentLocation.id': `${this.props.currentLocation}`,
      },
    })

Upvotes: 3

Related Questions