Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Notify zapier with firebase changes
var firebase = require("firebase");
var request = require("request");
var db = require('./database');
var notifyZapierOfJobPost = function(snapshot){
var job = snapshot.val();
var key = snapshot.key;
var email = job.email;
if(job.sent_to_zapier) return; //ignore if already sent
if(!email) return; //ignore if email is blank
var zapierNewJobPost = 'https://hooks.zapier.com/hooks/catch/xxx/xxx/';
request({
url: zapierNewJobPost,
method: "POST",
json: job
});
db.ref('jobs/'+ key +'/sent_to_zapier').set(true);
}
var jobsRef = db.ref('jobs');
jobsRef.orderByChild('sent_to_zapier').equalTo(null).on('child_changed', notifyZapierOfJobPost);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.