18.05.2016 Views

Mittwoch, 18. Mai, 2016

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MongoDB CRUD the MVC way with Passport Authentication 56<br />

1 $ node server<br />

and issue the POST request with the following request body:<br />

1 {<br />

2 "name": "Kevin",<br />

3 "email": "kevin@mitnick.com",<br />

4 "username": "Condor",<br />

5 "password": "AintNoBodyGotTimeForGoodPa$words!!!"<br />

6 }<br />

You can use the curl command like this:<br />

1 $ curl -X POST -H "Content-Type: application/json" -d '{"name": "Kevin", "email"\<br />

2 : "kevin@mitnick.com", "username": "Condor", "password": "AintNoBodyGotTimeForGo\<br />

3 odPa$words!!!"}' localhost:1337/users<br />

but I suggest you use a GUI tool since it will make things easier. I personally use Postman¹¹⁰ in<br />

Chrome, but I’m sure there’s also a dozen of plugins for your favorite browser. However, if you<br />

followed all the steps you will notice that this curl command or Postman’s POST aren’t working<br />

(sneaky, huh? ;)):<br />

postmanFail<br />

¹¹⁰https://www.google.hr/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;<br />

uact=8&amp;ved=0CB0QFjAA&amp;url=https%3A%2F%2Fchrome.google.com%2Fwebstore%2Fdetail%2Fpostman-rest-client%<br />

2Ffdmmgilgnpjigdojojpjoooidkmcomcm&amp;ei=GniuVMHZFYH9UMiSg9gC&amp;usg=AFQjCNFL71vN61QG0LKlw7VDJvIZDprjHA&amp;<br />

sig2=DUyqMgSFn1BFnWzvNlf_Sg

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!