0

I call another api in NodeJS express api with request payload using certificate with Post request type but the payload is not accepting. The problem is, how to feed the payload data with Post request inside the Node api?

Express Setting

Request Options with Payload and Certificate

Bunny
  • 87
  • 1
  • 7

2 Answers2

1

Just pass the payload with comma separated URL, Example : await axios.post('http://localhost:4000/createUser', data );

where data will be payload for another API

Saket Agarwal
  • 265
  • 2
  • 9
  • Thanks for your support. I am ok at this step, the payload is not accepting in another API, showing bad request. – Bunny May 25 '21 at 10:27
1

Here is an example with Axios

const axios = require('axios');

        var dataToPost = {
          email: "your email",
          password: "your password"
        };

        let axiosConfiguration = {
          headers: {
              'Content-Type': 'application/json;charset=UTF-8',
              "Access-Control-Allow-Origin": "*",
          }
        };

        axios.post('endpoint or url', dataToPost, axiosConfiguration)
        .then((res) => {
          console.log("Response: ", res);
        })
        .catch((err) => {
          console.log("error: ", err);
        })
Nabeel Sajid
  • 193
  • 6