Pipedream, getting trigger event data with sync function

197 views Asked by At

i'm wondering hot to get pipedream to do an nodejs action, but i need to use the trigger event (HTTP POST) to get some info, the thing is that i cant wonder how to make it work, this is my code:

var axios = require('axios');
var data = JSON.stringify({
  "response": [
    "XML",
    "PDF",
    "TIMBRE",
    "LOGO",
    "FOLIO",
    "RESOLUCION"
  ],
  "dte": {
    "Encabezado": {
      "IdDoc": {
        "TipoDTE": 39,
        "Folio": 0,
        "FchEmis": "2020-11-25",
        "IndServicio": "3"
      },
      "Emisor": {
        "RUTEmisor": "76795561-8",
        "RznSocEmisor": "HAULMERSPA",
        "GiroEmisor": "VENTA AL POR MENOR EN EMPRESAS DE VENTA A DISTANCIA VÍA INTERNET",
        "CdgSIISucur": "81303347",
        "DirOrigen": "ARTURO PRAT 527 CURICO",
        "CmnaOrigen": "Curicó"
      },
      "Receptor": {
        "RUTRecep": "66666666-6"
      },
      "Totales": {
        "MntNeto": 840,
        "IVA": 160,
        "MntTotal": 1000,
        "TotalPeriodo": 1000,
        "VlrPagar": 1000
      }
    },
    "Detalle": [
      {
        "NroLinDet": 1,
        "NmbItem": "Item1",
        "QtyItem": 1,
        "PrcItem": 1000,
        "MontoItem": 1000
      }
    ]
  }
});

var config = {
  method: 'post',
  url: 'https://dev-api.haulmer.com/v2/dte/document',
  headers: { 
    'apikey': '928e15a2d14d4a6292345f04960f4bd3', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

pipedreams is giving me this code to get the triggered event data, but i cant wonder how to get it work with my code

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {
    // Return data to use it in future steps
    return steps.trigger.event
  },
})

i was thinking it's a async thing, but i cant wonder how to do it with await, i hope you can help me

1

There are 1 answers

0
svikramjeet On

you can use send to post data to any external url like this

$.send.http({
 method: 'post',
  url: 'https://dev-api.haulmer.com/v2/dte/document',
  headers: { 
    'apikey': '928e15a2d14d4a6292345f04960f4bd3', 
    'Content-Type': 'application/json'
  },
    data : data
    method: "POST"
  })