auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const axios = require('axios');
const url = require('url');
this.siteName = url.parse(params.siteUrl).hostname;
axios.interceptors.request.use((config) => {
config.meta = config.meta || {}
config.metadata = { startTime: new Date() }
return config;
}, function (error) {
return Promise.reject(error);
});
axios.interceptors.response.use((response) => {
response.config.metadata.endTime = new Date()
response.duration = response.config.metadata.endTime - response.config.metadata.startTime
return response;
}, (error) => {
error.config.metadata.endTime = new Date();
error.duration = error.config.metadata.endTime - error.config.metadata.startTime;
return Promise.reject(error);
});
// https://httpstat.us/400
// console.log(steps.query.$return_value.results);
let response = await axios.get(
params.siteUrl)
.then((result) => {
const { status, statusText, duration } = result;
return { status, statusText, duration };
})
.catch(function (error) {
// console.log(error);
if (error.response) {
console.log(error.response);
return error.response;
} else {
console.log('oops');
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
});
// for( var row in steps.query.$return_value.results){
// let [ name, url ] = steps.query.$return_value.results[row];
// if( url && url.slice(0,5) == 'https' ){
// // console.log(url);
// }
// }
return response;
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
if( steps.GET_website.$return_value.status === 200){
return false;
} else {
return true;
}
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
if( steps.contains_error.$return_value ){
const options = {
subject: params.subject,
text: params.text,
}
if (params.html) {
options.html = params.html
}
// if (params.include_collaborators) {
// options.include_collaborators = params.include_collaborators
// }
$send.email(options)
}
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, auths) => {
}
const data = steps.GET_website.$return_value;
const collection = steps.GET_website.siteName.replace(/\./g, "_");;
return await require("@pipedreamhq/platform").axios(this, {
method: "post",
url: `https://datawaves.io/api/v1.0/projects/${auths.datawaves.project_id}/events/${collection}`,
headers: {
"Authorization": `${auths.datawaves.secret_key}`,
},
data,
})