Axios 对象作为后端不可读的参数

Axios object as params not readable by backend

我的 axios 查询有问题:

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

查询需要是 typeof ?[...]offset=5&parentLocation.id=xyz,但现在是这样的:&offset=0&max=5&parentLocation={"id":"[object Object]"} 后端不知道如何处理。 有没有可能做到parentLocation.id=xyz?

试试这个,它应该有效

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