Skip to content

Instantly share code, notes, and snippets.

@tmzt
Created February 16, 2011 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmzt/828945 to your computer and use it in GitHub Desktop.
Save tmzt/828945 to your computer and use it in GitHub Desktop.
snippet of app.js
app.post('/apis/v0/checkemail.json', function(req, res) {
var email = req.body.email;
checkemail(email, function(result) {
console.log('result: ', result);
if (result != null && result.shorturl != '') {
console.log('shorturl: ', result.shorturl);
//res.writeHead(200, {'Content-Type': 'application/json'});
//res.end(JSON.stringify(result));
console.log('json: ', JSON.stringify({html: result.html}));
res.send(JSON.stringify({html: result.html}), {'Content-Type': 'application/json'}, 200);
} else {
res.writeHead(404);
res.end(null);
};
});
});
curl -d '{"email": "test@test.tld"}' http://jobitr.com/apis/v0/checkemail.json -H 'Content-Type: applation/json' -v
result: { '0':
{ email: 'test@test.tld',
created_on: Wed, 16 Feb 2011 01:38:33 GMT,
shorturl: '4Sem5W' },
_id: { id: 'M[*�»açë\u0006«\r7' } }
result: { shorturl: undefined,
html: 'Click <a href="http://jobitr.com/undefined">jobitr.com/undefined</a> to create your portfolio.' }
shorturl: undefined
json: {"html":"Click <a href=\"http://jobitr.com/undefined\">jobitr.com/undefined</a> to create your portfolio."}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment