You can integrate API requests into your automation workflows with CustomJS and Axios. The example below shows how to make a POST request to an API. By using CustomJS in Make.com, we have optimized the process with dynamic parameters that appear automatically when you use the “Execute a stored function” module.
Axios Request With Make.com
const axios = require('axios');
async function sendPostRequest() {
// 1. Create payload from Make.com input parameters
const payload = {
username: input.username,
password: input.password
};
try {
// 2. Send POST request to API and await response
const response = await axios.post('https://eokqlfv344gxnv0o.m.pipedream.net', payload);
console.log('Response:', response.data);
// 3. Return response data for downstream modules
return response.data;
} catch (error) {
console.error('Error:', error);
// 4. Return error object for error handling
return { error: error.message };
}
}
return sendPostRequest();