mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-04-20 06:41:03 +00:00
23 lines
421 B
CoffeeScript
23 lines
421 B
CoffeeScript
|
|
|
||
|
|
# Webhook Action Invoker
|
||
|
|
# ----------------------
|
||
|
|
|
||
|
|
# Sends data to a remote Webhook
|
||
|
|
|
||
|
|
options =
|
||
|
|
method: 'POST'
|
||
|
|
json: true
|
||
|
|
jar: true
|
||
|
|
|
||
|
|
exports.post = ( url, data ) ->
|
||
|
|
if not data
|
||
|
|
data = {}
|
||
|
|
|
||
|
|
options.url = url
|
||
|
|
options.body = data
|
||
|
|
request options, ( err, resp, body ) ->
|
||
|
|
if err or resp.statusCode isnt 200
|
||
|
|
log "Error in pushing data to webhook '#{ url }'!"
|
||
|
|
else
|
||
|
|
log "Successfully posted data to '#{ url }'"
|