0

I have the following angular post request :

this._http.post(
        RESOURCE_URL, // my query URL
        {
          params : {
            houses: ids
          }
        }
      );

the variable ids is an array of numbers that I send to the back end, with ids = [1,2] for instance. my issue is, as I send my request, it is sent as the following RESOURCE_URL?houses=1&houses=2, which is not what I want.

I'm trying to have it more like this : RESOURCE_URL?houses=[1,2].

Now one may suggest why I don't just pass it on to the request body. Problem is, for prject-specific reasons, I cannot. Too much work would be required and I do not have power to decide whether I should dive into it or not.

is there anyway this can be done ? because haveing looked at this topic and also this one, and it seems like it's just not possible.

1 Answer 1

3

It's possible, it's just not the way Angular does this. So, just do it manually.

this._http.post('my_url', {
  params: {
    houses: `[${ids.join(',')}]`
  }
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.