Home > Software engineering >  Axios object as params not readable by backend
Axios object as params not readable by backend

Time:03-20

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?

CodePudding user response:

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}`,
      },
    })
  • Related