Created
February 16, 2011 06:07
-
-
Save tmzt/828945 to your computer and use it in GitHub Desktop.
snippet of app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -d '{"email": "[email protected]"}' http://jobitr.com/apis/v0/checkemail.json -H 'Content-Type: applation/json' -v | |
result: { '0': | |
{ email: '[email protected]', | |
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