<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Javascript, jQuery, Angular, Firebase, Node, and MongoDB - Medium]]></title>
        <description><![CDATA[Let’s learn how to code. - Medium]]></description>
        <link>https://medium.com/javascript-jquery-angular-firebase-and-mongodb?source=rss----765b5ee62bd2---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Javascript, jQuery, Angular, Firebase, Node, and MongoDB - Medium</title>
            <link>https://medium.com/javascript-jquery-angular-firebase-and-mongodb?source=rss----765b5ee62bd2---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 10:31:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/javascript-jquery-angular-firebase-and-mongodb" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Node RESTful API with MongoDB — Example]]></title>
            <link>https://medium.com/javascript-jquery-angular-firebase-and-mongodb/node-restful-api-with-mongodb-example-d5c19d2a84a8?source=rss----765b5ee62bd2---4</link>
            <guid isPermaLink="false">https://medium.com/p/d5c19d2a84a8</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[express]]></category>
            <dc:creator><![CDATA[Daniel Falabella]]></dc:creator>
            <pubDate>Wed, 24 Jun 2015 02:57:59 GMT</pubDate>
            <atom:updated>2015-06-24T02:57:52.150Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eXH8ONhlA_Y0iWn2l-1n-w.jpeg" /></figure><h3>The whole server.js bacon:</h3><p>Mongoose rocks, but we’ll be using mongojs for simplicity’s sake.</p><p>First, make sure you npm install your dependencies: express, body-parser, cors, and mongojs.</p><p>Then, since I don’t want to write a long blog post, here is the code to make magic happen:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4952e97cc4c103eb35fb7fe83e9cfc7/href">https://medium.com/media/a4952e97cc4c103eb35fb7fe83e9cfc7/href</a></iframe><h3>Final note</h3><p>Yay!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5c19d2a84a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb/node-restful-api-with-mongodb-example-d5c19d2a84a8">Node RESTful API with MongoDB — Example</a> was originally published in <a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb">Javascript, jQuery, Angular, Firebase, Node, and MongoDB</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RESTful API Example — with Node and Express]]></title>
            <link>https://medium.com/javascript-jquery-angular-firebase-and-mongodb/restful-api-example-with-node-and-express-fe65932705c6?source=rss----765b5ee62bd2---4</link>
            <guid isPermaLink="false">https://medium.com/p/fe65932705c6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[express]]></category>
            <dc:creator><![CDATA[Daniel Falabella]]></dc:creator>
            <pubDate>Wed, 24 Jun 2015 02:44:09 GMT</pubDate>
            <atom:updated>2015-06-24T02:43:50.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ImihO3FTglMRYDN07myEbg.jpeg" /></figure><h3>Set up your environment</h3><p>I won’t go into detail explaining what each thing does, but you a simple Google search will tell you.</p><p>My server.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44188b75846b20aaed870d2f258059bd/href">https://medium.com/media/44188b75846b20aaed870d2f258059bd/href</a></iframe><h3>The “hard” part</h3><p>Let’s deal with a <strong>GET</strong> api request (gives data back to the client):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e27e8563cd1ef4aba4fc94499bc077bd/href">https://medium.com/media/e27e8563cd1ef4aba4fc94499bc077bd/href</a></iframe><p>Let’s deal with a <strong>POST</strong> api request (lets the client save new data):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/670d2c427536fca71898ac2af0f337c0/href">https://medium.com/media/670d2c427536fca71898ac2af0f337c0/href</a></iframe><p>Let’s deal with a <strong>PUT</strong> api request (lets the client modify data):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86a9cd3c873c73e2ccaed9acf7826d8c/href">https://medium.com/media/86a9cd3c873c73e2ccaed9acf7826d8c/href</a></iframe><p>Let’s deal with a <strong>DELETE</strong> api request (lets the client… hum.. DELETE data):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df717b9ee17eb7d67cb24c0982202e8d/href">https://medium.com/media/df717b9ee17eb7d67cb24c0982202e8d/href</a></iframe><p>Noticed that .delete does not accept an object, rather, it accepts parameters which you can access through:</p><pre>req.paramas.passedId</pre><p>… passed from the URL:</p><pre>&#39;/api/delete/:passedId&#39;</pre><h3>Betrayed</h3><p>I feel like I betrayed you… this was too simple.</p><p>I. AM. SO. SORRY.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe65932705c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb/restful-api-example-with-node-and-express-fe65932705c6">RESTful API Example — with Node and Express</a> was originally published in <a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb">Javascript, jQuery, Angular, Firebase, Node, and MongoDB</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serve a static file with express — example]]></title>
            <link>https://medium.com/javascript-jquery-angular-firebase-and-mongodb/serve-a-static-file-with-express-example-f8ba493951a8?source=rss----765b5ee62bd2---4</link>
            <guid isPermaLink="false">https://medium.com/p/f8ba493951a8</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Daniel Falabella]]></dc:creator>
            <pubDate>Wed, 24 Jun 2015 02:17:54 GMT</pubDate>
            <atom:updated>2015-06-25T02:20:18.461Z</atom:updated>
            <content:encoded><![CDATA[<h3>Step 1: Install Express</h3><p>cd to the your code file and on your terminal run:</p><pre>npm install express</pre><h3>Step 2: Require Express</h3><p>This is node’s way to access and use modules (i.e. code someone else wrote):</p><pre>var express = require(&#39;express&#39;);</pre><h3>Step 3: Serve your static page</h3><p>If index.html is located on the same directory as the server file, the following code will serve your index.html file:</p><pre> app.use(express.static(__dirname + &#39;/&#39;));</pre><h3>Step 4: Drink some hot cool-aid</h3><p>Because your rocked it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jdKKWgQrPhXEh6PSqsC6OQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8ba493951a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb/serve-a-static-file-with-express-example-f8ba493951a8">Serve a static file with express — example</a> was originally published in <a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb">Javascript, jQuery, Angular, Firebase, Node, and MongoDB</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular’s $q.defer() Example]]></title>
            <link>https://medium.com/javascript-jquery-angular-firebase-and-mongodb/angular-s-q-defer-example-78867ecfa7d8?source=rss----765b5ee62bd2---4</link>
            <guid isPermaLink="false">https://medium.com/p/78867ecfa7d8</guid>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Daniel Falabella]]></dc:creator>
            <pubDate>Sat, 20 Jun 2015 19:55:37 GMT</pubDate>
            <atom:updated>2015-06-20T19:56:05.326Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are familiarized with promises this will be a piece of cake. If not, it will be a piece of muffin :)</p><h3>Let’s gif this thing up</h3><p>Ok, let’s be honest, tutorials and examples are typically pretty boring. So let’s do the following: let’s build a chat room where every time you write something, it replaces that text with a gif! To do that, we will be communicating with <a href="https://api.giphy.com/">Giphy’s API</a>.</p><h3>My code structure</h3><p>Index.html → my <em>view</em>.</p><p>MainController.js → define Angular <em>app</em> and code for my (only) <em>controller</em>.</p><p>getDataService.js → a <em>service</em> I will use to get my data from Giphy!</p><h3>Let’s get some gifs!</h3><p>First, let’s make sure we can get some gifs. Since the getDataService will be the file handling all interactions with Giphy’s API, let’s start there:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a10ad3f8420c7baac0da3fe145b3abd/href">https://medium.com/media/5a10ad3f8420c7baac0da3fe145b3abd/href</a></iframe><p><strong>There you have it! Console-logging the results will give you a nice object containing an array of ~25 (max) GIFs.</strong></p><p>Ok cool, but I don’t want to have the searchQuery hardcoded on my service, I want the user to type the query and pass that to my service through my controller. Let’s do that.</p><p>My index.html:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/859d6eb9f0d3e9e9d99f950b57d307dd/href">https://medium.com/media/859d6eb9f0d3e9e9d99f950b57d307dd/href</a></iframe><p>My MainController:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/137588f195daaf38601dd05b3bf746c9/href">https://medium.com/media/137588f195daaf38601dd05b3bf746c9/href</a></iframe><p>My getDataService:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac705a190d2679e98a3aa1789be80da5/href">https://medium.com/media/ac705a190d2679e98a3aa1789be80da5/href</a></iframe><p>This works and stuff, but… how do I pass the data back to the controller? You can pass a callback to the service or you can use promises!</p><h3>Angular’s $q.defer() promises</h3><p>A promise object is used for deferred and asynchronous computations. The key here is the word <em>asynchronous. </em>The simplified version is that putting an API request takes time to get back to you. Javascript has no idea when that time will be, and does not want to sit around on that line of code until data comes back.</p><p>Promises allows Javascript to move forward reading the code, and whenever data comes back, execute Javascript code (and reflect the changes on the front end — which is what we want).</p><p>For this, we’ll have to make a couple of modifications to our service and to our controller.</p><p>The service will return a promise to the controller, and once the service gets the data, the controller will do something with that data (on our case, we want it to make a change on our view).</p><p>All together now: My service (remember to inject $q):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/595794d902a420321e0dc01d79aef09a/href">https://medium.com/media/595794d902a420321e0dc01d79aef09a/href</a></iframe><p>My controller:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8d7e0aa0ac2637b2de0113de275045d/href">https://medium.com/media/b8d7e0aa0ac2637b2de0113de275045d/href</a></iframe><p>My index.html:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee1b2ce7f4d961caae616646f1649d41/href">https://medium.com/media/ee1b2ce7f4d961caae616646f1649d41/href</a></iframe><p>The end result :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*HPVDlEMokKIg9WKhWaU5Xw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78867ecfa7d8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb/angular-s-q-defer-example-78867ecfa7d8">Angular’s $q.defer() Example</a> was originally published in <a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb">Javascript, jQuery, Angular, Firebase, Node, and MongoDB</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular’s $q.defer and $q.all are cool. I promise.]]></title>
            <link>https://medium.com/javascript-jquery-angular-firebase-and-mongodb/angular-s-q-defer-and-q-all-are-cool-i-promise-992bfd401f11?source=rss----765b5ee62bd2---4</link>
            <guid isPermaLink="false">https://medium.com/p/992bfd401f11</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Daniel Falabella]]></dc:creator>
            <pubDate>Sat, 06 Jun 2015 23:00:30 GMT</pubDate>
            <atom:updated>2016-06-11T14:54:47.034Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*defNc8qkOY65hlGy_46Jcw.jpeg" /></figure><p>So, what’s the fuzz about promises and what’s the “angular’s way” of doing them?</p><h3>Let’s make a $35 billion company</h3><p>Let’s say we are building Twitter, (and to keep things simple) we’ll have two collections on your database: users and tweets. Each user has a list of tweet ids associated with that user.</p><p>Once a user logs in, we’ll have 2 api requests to make: 1- <em>get</em> the users, 2- <em>get </em>the tweets associated with the user. Once I get the users and the tweets, we want to run a for loop to connect each tweet with its appropriate user.</p><h3>The problem</h3><p>Ok. So… how will we know when we get the data back (our users data <strong>and</strong> our tweets data)? It could take 2 or 8 hundred mini-milliseconds! By then all of your code would have run and all of your page rendered.</p><h3>How do we fix this?</h3><p>We use promises. Promises allows us to “put a hook” on the api request, and change its status when we get the data back. Once the status changes, a function will be invoked.</p><p><strong>$q.defer is the vehicle that Angular uses to make that happen.</strong></p><p>So now we can invoke a function when we hear back from Twitter’s api, but how would we know when we hear back from both of the functions. Remember we only want to connect each tweet with the user, once we have <strong>both </strong>the user <em>and</em> the tweets.</p><p><strong>$q.all allows us to trigger a response once all of our api requests and responses have been completed.</strong></p><p>Again, we use $q.defer to trigger a response when we hear back from an api request, and we use $q.all (combined with $q.defer) to trigger a response function when we hear back from all of our api requests.</p><h3>The code</h3><p>I will have a controller that will rely on my getData service to get the data from the api. Whenever I get the data from the api, I’ll give the data back to the controller. and then, display the data on my page.</p><p><strong>Controller:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a438fd8be85587cc57f85e991dbd0c1/href">https://medium.com/media/9a438fd8be85587cc57f85e991dbd0c1/href</a></iframe><p><strong>Service:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09a245c78cde92363d56e89e709b3a65/href">https://medium.com/media/09a245c78cde92363d56e89e709b3a65/href</a></iframe><h3>Wtfetch just happened?</h3><p>We defined all of our promises. In this case, we named them one, and two.</p><p>Once our first requests comes back successfully we resolve <em>one</em> and pass the response. If there was an error associated with it, we reject it ☹</p><p>Now we need to wait for the second request to come back (or maybe it came back first!). If it was successful, we resolve it. If it wasn’t we reject it.</p><p>Once both of your promises are resolved, the <em>all</em> variable triggers its response on the controller’s end. We use a <em>.then</em> to catch that. There, we receive as many arguments as we resolved $q.defer() on our service. In this case we get two arguments, one with our user data and the other one with our tweets data.</p><p>We can now connect each tweet with its respective user. Voila! You read the whole blog post… I can’t believe it.</p><p>If you forget what methods are built into $q.defer(), try console-logging-it. You’ll see something like this:</p><pre>-notify: function...<br>-promise: d...<br>-reject: function...<br>-resolve: function...</pre><p>This should remind you, that you can invoke notify, reject, or resolve (don’t worry too much about notify), and you should return your promise.</p><p>As a last note, I feel obligated to refer you to Angular’s docs (although they suck): <a href="https://docs.angularjs.org/api/ng/service/$q">https://docs.angularjs.org/api/ng/service/$q</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=992bfd401f11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb/angular-s-q-defer-and-q-all-are-cool-i-promise-992bfd401f11">Angular’s $q.defer and $q.all are cool. I promise.</a> was originally published in <a href="https://medium.com/javascript-jquery-angular-firebase-and-mongodb">Javascript, jQuery, Angular, Firebase, Node, and MongoDB</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>