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?
Asked
Active
Viewed 647 times
2 Answers
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
-
Thanks for your support. May I know how to provide Certificate with Axion. – Bunny May 25 '21 at 10:38
-
1kindly check this answer https://stackoverflow.com/a/53585725/14413302 – Nabeel Sajid May 25 '21 at 10:44