0

I use angular 4.4.6 and I want to send a http request to swagger-enabled endpoint. I want to send a number there, but it always being sent as a string.

approve(id1: number){

 .....

let params={id:id1}

return this.http.post(approveUrl, params)
            .map(this.extractData)
            .catch(this.handleError);

But I want to send number, not string, not anything else.

In my swagger:

        parameters:
          - name: body
            schema:
              required:
                - id
              properties:
                id:
                  description: Priority order
                  type: number
                  format: int32
            in: body
            required: true

I always get 400 (Bad request) except one case: {id: 5}, where 5- any hardcoded number.

How to create a simple and bulletproof solution to send number?

1 Answer 1

1

try this to convert it to number :

let params={id:+id1}
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.