{"componentChunkName":"component---src-templates-blog-post-js","path":"/restful-api-mlab-raspi/","result":{"data":{"site":{"siteMetadata":{"title":"Justin is a Maker","author":"Justin Smith"}},"mdx":{"id":"0f3b6dc9-a596-5e18-b6d2-7096ec85a7aa","frontmatter":{"title":"Creating a RESTful API on a Raspberry Pi with mLab","date":"February 02, 2017","externalLink":null,"teaser":"Learn how to use mLab's cloud-hosted MongoDB instances to make MERN development on the Pi a lot easier."},"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Creating a RESTful API on a Raspberry Pi with mLab\",\n  \"date\": \"2017-02-02T00:00:00-0500\",\n  \"teaser\": \"Learn how to use mLab's cloud-hosted MongoDB instances to make MERN development on the Pi a lot easier.\",\n  \"featuredImage\": \"mlab-logo.png\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"The Raspberry Pi tends to end up in a lot of projects that benefit from collecting, storing, and analyzing data\\u2013when you have a full computer that costs 35 bucks, it makes sense to attach it to everything! There are plenty of options of how to store the data you collect, but my absolute favorite so far has been working with MongoDB through mLab. This post will walk you through setting up a basic server in Node that will let you push data from you Pi up to mLab\\u2019s cloud-hosted MongoDB instances.\"), mdx(\"div\", {\n    \"className\": \"image-container large-image\"\n  }, \"\\n  \", mdx(\"span\", {\n    parentName: \"div\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"640px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/647875466ca07a743e5cef05b3bc0087/6af66/mlab-logo.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"75%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAABfklEQVQoz2PQz59MNmIYBJr18qbo5E01yJ9EmmaD/MlAbWZFE5zKO7VypwG5+nmTIEgvH2QiUI1hAchQ3fwpEAZUM1Cpbt4U08IJu2dbP1yvGN9cpp4z07B4mkHRdL2iGeZFE+yKu4AK1HNm6OZNtSjqU86ZBTQRrnmSes70kNrGbR0qa5ol2yZGK6ZN048p1YurUo6si6osae1KUM2ZmdlYmFJfsmSyb35TjknBBIh+kGaNnOkB1Y2bW+W3tgnU9sYpRTXresdpeycoeqbHZEY1dGcY509YNMn/yByrNVM9urtjqtvSlLJnGRVMBDlbO3eyQ/nEukl9tZN6YrqmqEXX6EWX6UaXqUZW+6clbZntMbU3dNEkv63TnTdPd5k5IRjoBLWcGUDPQ0J7kn7BdOeOQx7dp8wrl+vl9IFCK3eCfu5Eg7yJLmVt9iWdTqUd1kU9QIZHeYs2OAiRowoYthOhCOQfBNLKnQpUrZU3DRjsEMagSmHkaDYsmEI2AgBhE2yJnor1QAAAAABJRU5ErkJggg==')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"mLab Logo\",\n    \"title\": \"mLab Logo\",\n    \"src\": \"/static/647875466ca07a743e5cef05b3bc0087/6af66/mlab-logo.png\",\n    \"srcSet\": [\"/static/647875466ca07a743e5cef05b3bc0087/5a46d/mlab-logo.png 300w\", \"/static/647875466ca07a743e5cef05b3bc0087/0a47e/mlab-logo.png 600w\", \"/static/647875466ca07a743e5cef05b3bc0087/6af66/mlab-logo.png 640w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\"\n  }), \"\\n  \"), \"\\n    \"), \"\\n  \", mdx(\"a\", {\n    parentName: \"div\",\n    \"className\": \"image-caption\"\n  }, \"mLab Logo\")), mdx(\"h3\", null, \"Creating a mLab Account\"), mdx(\"div\", {\n    className: \"paragraph-with-picture\"\n  }, mdx(\"p\", null, \"mLab has enterprise options for larger companies that use their service, but they also have a 0.5 GB free tier that's great for smaller projects like this. Go ahead and sign up for an account\\u2013once you're logged in, we can get you started on what kind of deployment you'll need. We'll be using a sandbox environment. To create a new sandbox, click the \\\"create new\\\" button\\u2013this will take you to the configuration screen.\", mdx(\"br\", null), mdx(\"br\", null), \"I prefer to run my instances on AWS, but you can also run on Google Cloud or Microsoft Azure. For this tutorial, let's select AWS. You can pick what region you'd like to run your AWS instance from, but for general-purpose applications, the default of US-East-1 is pretty solid. Click \\\"single node\\\" to reveal the smaller options, and then click \\\"sandbox\\\" to choose our deployment type. There's only one version of MongoDB available for sandbox accounts, so you can just let the version stay as-is. The last thing we need to do is come up with a name for our database\\u2013let's call ours \\\"pi_test_databse\\\".\"), mdx(\"div\", {\n    \"className\": \"image-container small-image\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"div\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"594px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/70372643bcaf1ff2932bd98ba8cc8169/5fd3e/mlab-config.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"185.33333333333334%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAlCAYAAABCr8kFAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFsElEQVRIx5VW2W9UdRSed6NRllLazr7v+z539mlnhpnpNoVSOiC2QCDiC0ZciBAJsSgoMcEEDKCgPmh89Al9NTHRxAR50WgMvpmof8LnOWfuHae1BXz4eu690/vds3zn/I7O6E/CFMpi1OzCbouX4MGYtW818P24zSd2Mwz/pvNEMphdPIT5/YfQnFtEe34/Ot0D6B0+irl9PXQXe6jU2xgzu+XFzaCRMnQmTwThTBnBVBH+RB4BZQr+fBPhYguR8jQCdB2ka2eiCJsvBnsgIbD54wKLN7qecMLuh9EdgtkdhsEZhDmcgzVegiVWJFuGJVqALVGBhdIyId74Ng15QOgMJhDNVeGNFxHL12D1hPDEtjE8tVMveHrUSHYCTxK2T9gwYfdtGboQjtsDeP3NNVy/cQXXbn+KF89ewCtnz+Pchbfw0plzWH3+FF47fxFvrF3G3t4KRozOft62KJJuxBLEvXt38feDr/Hd9z/gq2++xU8//4LfHjzAj/fv47Mv7+L+r7/jjz//wvvXb2LbuBWcpi09HKXq5RqzaC2tYunoScwur2DfwVX0Vo6TPYJZqvTy4WN0vYJcrS05fGjIZqqyO5wSDQZSJeSqLcQyJSSUKtLFKSQor7FcBZ5oBmbSLHs3ZvVsqUmdg4qSoS/bc3tgybVgTlQxSl6M0AdGzF6x/GWDIwAjqWAdXIyQiqAasskJY+8M7K9+DNfpW6isfY76218gcOYObC9/BMfpm0hUO0gpFcTJ08nWPIl/Cc2ZfZhsz8uzJEXBVk8f1Y2Tm4ZYGUbyzphpwKK0BGby2MTINmHyRGFSvWG9WrwRcKrMnrA8M7GHTtVDjttg88IdiMHlj8IdjIu1OP2wugIC7gir2hVmglgitPiisFL3MNg7ySH/sfri0nqBZAG+WE5eMjhDfbhC0kEG53C+hjD0fCCbaLaMhQPPYYYkMtXuwhVKgYeGN5oVq107g8nNQb3tILACxEM7heMlzzz0EttwuoxQukS2JJ6HCEHynondGxFOS1T828DDmFJDd3kVC70jqHX2olCfIRF3kCw1kCo3kSr1kSjUER8C30dzNXqHKt5ZkNmp4z8BGlsV7pa5JZFCNFsVr6LZCiI02jQ41NA0cLhWynciPwml0iRCN3lIhBxOjfTV6S6jPr2AOHnMBDHqFiaPEDFPJO4ojUgDp0uh7uoTev4lrO6ZQ4sE2yBC/iLnj4vFXoaFvCZ52kjI9wp1GrfpGBNqTc25ZOwy9Ue9SMURHEjmkSAdDorClZxZ6KFDHra7S8iU65IbDkeDbcjyUSBQr7XnQshxc9nLVJRSfRqlxgyylA/OGYcbVfMXUcPn/MboXgPf++OKEA90yLmI0MgKqZrzx/MD7Q2DP+yLKULA12wZrBIW/sBDflAi7TVnF6nac1JhJmQbVgUepg9yAYbTwPecmnSxTpXeo1bZ7KGXWTZdyt8BVTaT/coOha3pcH2F+1UuTk0jp8lm90CHXUzv7YlsmMhHobBnnCNNl3xCbuxjJsxPtpGhrhLZyPhSpzGPIJ7ggYQi4CHBiebfHyUbvSYbPnR4nrkjaXoYxKEjJ3Dx0rtYu3QFK8dfwA6946F7zX/OFA55l8m1TtjDS9O4ui087KRbd+rx9HWGkjLauWJ6CpE3hO16u1gmnrD9D0JefA6unsDhYydxkM7ipWePIl9roTDVpup1RLBM+tiEvFocP3kK77x3FRcvX8HVazdw48M7+ODWbdy6/Qmy5QZ2GhzqefwYOeQe5EnNLz1DawavGlq4W4XMCxN/QINe7FAOa+0FqbJ2bozTKaj9s5AMrWzsxYjRLQ4wdjBICSNU2DGt9co0EAqUry4dVBwiV32zDXU3WbPLj6RSkIGqVBrIV5soTtL6ki2JIzIPd6mS4XyOqquvkGxYJpnQ5PQhkkwjTgQJRq4sW0UwnhXCfwDN3622G4uUKAAAAABJRU5ErkJggg==')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"Configuration for a Sandbox Deployment\",\n    \"title\": \"Configuration for a Sandbox Deployment\",\n    \"src\": \"/static/70372643bcaf1ff2932bd98ba8cc8169/5fd3e/mlab-config.png\",\n    \"srcSet\": [\"/static/70372643bcaf1ff2932bd98ba8cc8169/5a46d/mlab-config.png 300w\", \"/static/70372643bcaf1ff2932bd98ba8cc8169/5fd3e/mlab-config.png 594w\"],\n    \"sizes\": \"(max-width: 594px) 100vw, 594px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\"\n  }), \"\\n  \"), \"\\n    \"), \"\\n    \", mdx(\"a\", {\n    parentName: \"div\",\n    \"className\": \"image-caption\"\n  }, \"Configuration for a Sandbox Deployment\"), \"\\n  \")), mdx(\"h3\", null, \"Adding a user to our database\"), mdx(\"p\", null, \"Once your mLab deployment is created, go ahead and click into it, then click the \\u201Cusers\\u201D tab. We\\u2019ll need to add an admin user to interact with our database. Create a user called \\u201Cadmin\\u201D with a strong password, and leave the \\u201Cread-only\\u201D box un-checked.\"), mdx(\"h3\", null, \"Setting up Node on a Pi with NVM\"), mdx(\"p\", null, \"If you\\u2019re running the latest instance of Raspbian Jessie, the Pi should already have Node installed. If you need help getting your Pi set up with Raspbian, \", mdx(\"a\", {\n    href: \"/ansible-pi\",\n    target: \"_new\"\n  }, \"check out my other blog post about standing up a headless Pi with Ansible\"), \". We could certainly run with this pre-installed version of Node, but it\\u2019s a very old version, and we want the new shiny stuff. In addition to that, we want to be able to switch between versions for different projects. To handle this switching, we\\u2019re going to install something called \", mdx(\"a\", {\n    href: \"https://github.com/creationix/nvm\",\n    target: \"_new\"\n  }, \"Node Version Manager\"), \", or NVM for short. \", mdx(\"a\", {\n    href: \"https://github.com/blobsmith/raspberryTestNode/wiki/Node.js-installation-with-nvm-on-Raspberry-pi\",\n    target: \"_new\"\n  }, \"Here\\u2019s the set of instructions that I\\u2019ve followed to accomplish this.\"), \" Feel free to hop over to Blobsmith\\u2019s GitHub and follow his guide, or you can just keep reading here to get the gist of it.\"), mdx(\"p\", null, \"First off, we need to download NVM. Do this by running \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout v0.33.1\"), \" on your Pi. This clones the repo to a \\u201C.nvm\\u201D folder inside our home folder, then checks out the latest code. At the time of this post, the latest is version 0.33.1, but you should change that to the latest stable version when you\\u2019re doing this on your own. Next, we need to add the command to source NVM to our .bashrc and .profile files. Do this by executing the following commands on your Pi:\"), mdx(\"ul\", null, mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"sudo nano ~/.bashrc\")), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Add \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"source ~/.nvm/nvm.sh\"), \" to the end of the file\"), mdx(\"li\", {\n    parentName: \"ul\"\n  }, mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"sudo nano ~/.profile\")), mdx(\"li\", {\n    parentName: \"ul\"\n  }, \"Add \", mdx(\"inlineCode\", {\n    parentName: \"li\"\n  }, \"source ~/.nvm/nvm.sh\"), \" to the end of the file\")), mdx(\"p\", null, \"It\\u2019s a good idea to leave a comment for yourself so you know why that extra line is there. You can do that by starting a new line with the \\u201D#\\u201D sign. After you\\u2019ve saved those files, reboot your Pi and SSH in again.\"), mdx(\"p\", null, \"When you\\u2019re back in, type \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"nvm\"), \" to see if the install worked. You should get the manual page for NVM. We\\u2019re going to start by installing the latest stable version of Node\\u2013do this by running \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"nvm install stable\"), \". Once that\\u2019s done, if you type \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"nvm ls\"), \", you should see two versions of Node installed\\u2013one for the stable version we just added (v7.7.3 in this case), and one for the system version. Congrats, you\\u2019re now able to install multiple versions of Node on your Pi!\"), mdx(\"h3\", null, \"Creating our project\"), mdx(\"p\", null, \"In your home directory, make a new directory called \\u201Cpimlabtest\\u201D and cd into it by running \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"mkdir pimlabtest && cd pimlabtest\"), \". We\\u2019ll start by telling this directory to use the version of Node that we just installed. Run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"nvm use stable\"), \" to accomplish this. Next, we\\u2019ll run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"npm init\"), \" to get us set up to pull packages from Node Package Manager. Feel free to enter the fields that it asks you for if you\\u2019d like, or you can just hit enter a few times to accept the defaults. If we \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"ls\"), \" in that directory, you should see that NPM added a package.json for us to keep track of all of our modules. We\\u2019re going to start by installing a few packages\\u2013run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"npm install --save express mongoose body-parser ip request node-cron\"), \". This will get us set up to start scaffolding our project. It\\u2019s worth noting that this will only install these packages in this specific node_modules directory for this specific version of Node that we set with NVM.\"), mdx(\"p\", null, \"Next, create a file called \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"server.js\"), \" by typing \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"nano server.js\"), \". This will bring you into the nano editor where we can start writing our code. Let\\u2019s start with our basic module declaration and server setup. Enter the following code:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" express \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'express'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    mongoose \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'mongoose'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    bodyParser \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'body-parser'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    ip \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'ip'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    request \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'request'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    cron \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'node-cron'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    app \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"express\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    port \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token number\"\n  }, \"8000\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\napp\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"listen\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"port\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\nconsole\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'server listening on port'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"port\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Now that we have that file created and our packages installed, you should be able to run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"node server.js\"), \" and get a message back that the server is listening on port 8000.\"), mdx(\"h3\", null, \"Setting up basic routes\"), mdx(\"p\", null, \"We\\u2019ll continue building our database interactions out by scaffolding our basic CRUD operations (create, read, update, delete). If you\\u2019ve got all of those bases covered, there isn\\u2019t much that you can\\u2019t do with this database. Let\\u2019s start by creating a few directories to organize our project. Create an app directory, and then inside that create a routes directory. After you\\u2019ve created those two folders (\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"mkdir app && mdkir app/routes\"), \"), create an index.js file in your routes directory by typing \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"nano app/routes/index.js\"), \". We need to tell Express to route our index route through something called \\u201Cmiddleware\\u201D. Middleware exists to help us work with the data between Node and database\\u2013the most important this we\\u2019ll be using it for is to grab the request and response objects. Enter the following code in this file:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" express \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'express'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    router \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" express\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"Router\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    bodyparser \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'body-parser'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// router middleware\"), \"\\nrouter\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"use\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token parameter\"\n  }, \"req\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" res\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" next\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"next\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\nrouter\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"route\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'/'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"post\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token parameter\"\n  }, \"req\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" res\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n    console\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'Index route is good!'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\nmodule\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), \"exports \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" router\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Once that file is good, we need to go back over to server.js and tell it about the work that we just did. It\\u2019s a good time to mention that you can certainly test this application through something like \", mdx(\"a\", {\n    href: \"https://www.getpostman.com/\",\n    target: \"_new\"\n  }, \"Postman\"), \", but we\\u2019re going to be doing the same thing in our server code by using the Request and IP packages.\"), mdx(\"p\", null, \"To start, let\\u2019s tell our server code about our IP address. We\\u2019ll use this to route our requests to the Pi\\u2019s IP. Add the following code to your server.js file right under our other variable declarations:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" myIp \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'http://'\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"+\"), \" ip\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"address\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"+\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"':'\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"+\"), \" port\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"While you\\u2019re at it, you can also replace our console.log statement in server to log the full IP and port. Change \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"console.log('server listening on port',port);\"), \" to \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"console.log('server listening on',myIp);\"), \". Run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"node server.js\"), \" again and you should get your IP listed out.\"), mdx(\"p\", null, \"Now we need to tell server.js about our index route. Since we exported the module as router at the bottom of the \\u201Capp/routes/index.js\\u201D file, we can reference that router in other files now. Include the following code in server.js to do so:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// Include routes\"), \"\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" indexRoute \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'./app/routes/index.js'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// Register routes\"), \"\\napp\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"use\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'/'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" indexRoute\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"So we\\u2019ve told our server.js about the route, but it still isn\\u2019t doing anything. This code won\\u2019t actually produce a result until we make a request to ask it to do so\\u2013this is where our IP declaration and the request package come in. We\\u2019re going to enter the following code in server.js right under our console.log statement to handle that action:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// request the index route\"), \"\\nrequest\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"post\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"myIp \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"+\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'/'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Now when you restart your server (\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"node server.js\"), \"), you should see the original console.log, along with another that says, \\u201CIndex route is good!\\u201D This means that our routing is hooked up and ready to go!\"), mdx(\"h3\", null, \"Telling our app about the database\"), mdx(\"p\", null, \"We\\u2019ve got our main route covered, now we need to tell the app about the database that we\\u2019ll be working with. We\\u2019ll start by making another directory inside \\u201Capp\\u201D called \\u201Cmodels\\u201D. Inside that models directory, we\\u2019ll create a file called \\u201CpiMlabTestDatabase.js\\u201D. In this new file, we\\u2019ll use Mongoose, an object modeling package that makes working with MongoDB a lot easier. We\\u2019ll need the database URL to get started here\\u2013go back over to mLab in your browser, click into your database, and look for a message at the top of the page that says \\u201CTo connect using a driver via the standard MongoDB URI\\u201D. We need to copy that full URL underneath that line. Now let\\u2019s go back over and edit our piMlabTestDatabase.js file that we created on our Pi. Enter the following code\\u2013make sure to replace the credentials sections (dbUser, dbPassword, yourDBUrl, yourDBName) with the URL that you just grabbed:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" mongoose \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'mongoose'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" mongoAddress \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'mongodb://<dbUser>:<dbPassword>@<yourDBUrl>/<yourDBName>'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" options \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n  server\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n    socketOptions\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n      keepAlive\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token number\"\n  }, \"300000\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" connectTimeoutMS\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token number\"\n  }, \"30000\"), \"\\n    \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n  replset\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n    socketOptions\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n      keepAlive\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token number\"\n  }, \"300000\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" connectTimeoutMS \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token number\"\n  }, \"30000\"), \"\\n    \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \"\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\nmongoose\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"connect\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"mongoAddress\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" options\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\"), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Once we have that file saved, we can go back to server.js and tell the server about our mLab connection. Add the following line to server.js above where you declared your route.\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// Include models\"), \"\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" db \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'./app/models/piMlabTestDatabase'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Restart your app to make sure everything works\\u2013we should still only be getting the two console.log statements.\"), mdx(\"h3\", null, \"Defining a model\"), mdx(\"p\", null, \"Now that we have our database hooked up, we need to tell it what kind of data we actually want to upload. Let\\u2019s start by determining what data we want to store\\u2013say that you have a Pi that you\\u2019re using as an awesome media player, and it sits on a sunny ledge in your living room. We want to track the temperature of our Pi to make sure that it isn\\u2019t getting too hot in the sun, so we\\u2019ll create a model to log that temperature. Start by creating another file in your models directory called \\u201CpiTempModel.js\\u201D, then enter the following code in it:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" mongoose \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'mongoose'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" PiTempSchema \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" mongoose\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"Schema\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n    timestamp\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), \" Date\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"\\n    temp\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \":\"), \" Number\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\nmodule\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), \"exports \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" mongoose\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"model\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'PiTemp'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" PiTempSchema\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"All we\\u2019re doing here is telling our MongoDB the name and what kind of data we\\u2019ll be storing. We\\u2019ll create a timestamp to help us analyze our data, and then ask the system what the current temperature is and return it as a number. Once again, we\\u2019ll need to go back to server.js and tell it about this new model file. Enter the following code under the line where you included your database:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" piTempModel \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'./app/models/piTempModel'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"h3\", null, \"Creating a model\"), mdx(\"p\", null, \"We\\u2019ve got our model set up, so now we need to actually create the model. We\\u2019ll do this in our index route file. First we need to install another NPM package to be able to read the system temp. Run \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"npm install --save child_process\"), \" from the root of your project to install the new package, then navigate back to editing your routes/index.js file. That child_process package will only be used for this index route right now, so we can include that in the variable declarations at the top of the file.\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" exec \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'child_process'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), \"exec\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"We also need to tell this routes file about the model file we just created. Add the following line in your variable declaractions section of the /routes/index.js file to do that:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" PiTemp \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"require\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'../models/piTempModel'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Now we can get on to actually handling the action and creating a record in the database! We\\u2019ll include the code to get the current temperature and send it to the db inside your \\u201C.post\\u201D function in /routes/index.js. Here\\u2019s a quick rundown of how we\\u2019ll get the temperature:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, \"router\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"route\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'/'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"post\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token parameter\"\n  }, \"req\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" res\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n    console\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'Index route is good!'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n    getCurrentTemperature \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n      \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" child \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"exec\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'cat /sys/class/thermal/thermal_zone0/temp'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token parameter\"\n  }, \"err\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" stdout\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" stderr\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n        \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"if\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"err\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n          console\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'There was an error getting the current temp:'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"error\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n        \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"else\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" currentTemperature \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"parseInt\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"stdout\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"/\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token number\"\n  }, \"1000\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n          console\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'Current temp is:'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"currentTemperature\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'\\xBAC'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n        \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \"\\n      \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n    \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"If you restart your server, you should see the two original console.log statements, plus a new one that\\u2019s telling you the current temperature of your Pi in celsius. You\\u2019ll notice that we wrapped the getCurrentTemperature in an \", mdx(\"a\", {\n    href: \"https://developer.mozilla.org/en-US/docs/Glossary/IIFE\",\n    target: \"_new\"\n  }, \"IIFE\"), \", which means that the function will run as soon as it gets defined. Now we can move on to actually saving that to the database.\"), mdx(\"p\", null, \"We\\u2019ll need to add a timestamp to satisfy our model\\u2019s requirements, then all we need to do is actually send it. You can find how to do that in the following code:\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, \"router\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"route\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'/'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"post\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token parameter\"\n  }, \"req\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" res\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n    console\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'Index route is good!'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n    getCurrentTemperature \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n      \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" child \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"exec\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'cat /sys/class/thermal/thermal_zone0/temp'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token parameter\"\n  }, \"err\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" stdout\", mdx(\"span\", {\n    parentName: \"span\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" stderr\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n        \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"if\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"err\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n          console\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'There was an error getting the current temp:'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"error\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n        \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"else\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// add the date\"), \"\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" thisDate \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"new\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token class-name\"\n  }, \"Date\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// add a new instance of our model\"), \"\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" thisTemperature \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"new\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token class-name\"\n  }, \"PiTemp\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"var\"), \" currentTemperature \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"parseInt\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"stdout\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"/\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token number\"\n  }, \"1000\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// tell the model what data we want it to use\"), \"\\n          thisTemperature\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), \"timestamp \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" thisDate\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"toISOString\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n          thisTemperature\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), \"temp \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"=\"), \" currentTemperature\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token comment\"\n  }, \"// save the record to the db\"), \"\\n          thisTemperature\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"save\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token parameter\"\n  }, \"err\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n            \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"if\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"err\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n              res\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"send\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"err\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n            \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"else\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n              console\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"log\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'New temp recorded in the database as:'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \"currentTemperature\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'\\xBAC'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n              res\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"send\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'new temperature recorded to the db'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n            \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \"\\n          \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n        \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), \"\\n      \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n    \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n  \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Go ahead and restart your server. If everything is working correctly, you should see the console.log output that it saved the DB. Just to make sure, let\\u2019s hop back over to our mLab page in the browser. Refresh the page, and you should see that a new collection called \\u201Cpitemps\\u201D was created, and it now has one document in it. Congratulations, you just coded the first step to creating an API for your Pi! Click into the pitemps collection, and you should see a JSON output of the document with your current temperature reading and timestamp.\"), mdx(\"h3\", null, \"Setting up a cron job to read the temperature\"), mdx(\"p\", null, \"We\\u2019ve got one reading, but what we really want is to have our Pi report the reading every 20 minutes. We\\u2019ll use node-cron to do this back over in our server.js file. At the very end of your server file, we\\u2019ll add a cron job to use the request model to hit the main index route.\"), mdx(\"div\", {\n    \"className\": \"gatsby-highlight\",\n    \"data-language\": \"javascript\"\n  }, mdx(\"pre\", {\n    parentName: \"div\",\n    \"style\": {\n      \"counterReset\": \"linenumber NaN\"\n    },\n    \"className\": \"language-javascript line-numbers\"\n  }, mdx(\"code\", {\n    parentName: \"pre\",\n    \"className\": \"language-javascript\"\n  }, \"cron\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"schedule\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'*/20 * * * *'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \",\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token keyword\"\n  }, \"function\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"{\"), \"\\n  request\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \".\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token function\"\n  }, \"post\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"(\"), \"myIp \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token operator\"\n  }, \"+\"), \" \", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token string\"\n  }, \"'/'\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\"), \"\\n\", mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \"}\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \")\"), mdx(\"span\", {\n    parentName: \"code\",\n    \"className\": \"token punctuation\"\n  }, \";\")), mdx(\"span\", {\n    parentName: \"pre\",\n    \"aria-hidden\": \"true\",\n    \"className\": \"line-numbers-rows\",\n    \"style\": {\n      \"whiteSpace\": \"normal\",\n      \"width\": \"auto\",\n      \"left\": \"0\"\n    }\n  }, mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  }), mdx(\"span\", {\n    parentName: \"span\"\n  })))), mdx(\"p\", null, \"Now you should get an initial reading when you first start your server, and then an additional reading every twenty minutes as long as the Pi is running your server code.\"));\n}\n;\nMDXContent.isMDXComponent = true;"}},"pageContext":{"slug":"/restful-api-mlab-raspi/","previous":{"id":"e2ee9cd3-aae3-582c-bcb6-631d9c4ee4c1","fields":{"slug":"/lawton-academy/"},"frontmatter":{"title":"Lawton Academy"},"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Lawton Academy\",\n  \"date\": \"2017-01-29T00:00:00-0500\",\n  \"teaser\": \"A website redesign for a Lawton Academy, a school that focuses on bringing out the best in its students.\",\n  \"featuredImage\": \"lawton-academy-logo.png\",\n  \"externalLink\": \"http://lawtonacademy.com\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"Education is hard\\u2013there\\u2019s no two ways about it. I\\u2019ve only dipped my toe into the education arena through a few very limited engagements, but it\\u2019s been enough to reinforce the diehard gratefulness that I have for folks who were called to that line of work. My support of educators is also rooted in the fact that I come from a family chock full of them\\u2013I\\u2019ve got six in my immediate family! The majority of them teach at a small K-12 school in Southwest Oklahoma called the Lawton Academy of Arts and Sciences.\"), mdx(\"p\", null, \"The school was founded by my grandmother in 1999\\u2013she had just retired from a fifty-year career in various roles with public schools in Lawton. Her career culminated with her serving as the superintendent of a magnet school. People from the community came to her when she retired and asked her to start a non-religiously-affiliated private school. At the time the only options for private education in Lawton were Catholic or hardline Southern Baptist schools, and the town was losing people like surgeons and engineers that didn\\u2019t want to put their kids into that kind of education.\"), mdx(\"p\", null, \"The website for the school had been through a lot of iterations before I took it over. A few of the teachers were trying to rely on that famous Okie stubbornness to make a site generator stretch significantly farther than it was supposed to, but ultimately they were working harder than they needed to. I rebuilt the website for them with a custom WordPress theme and Advanced Custom Fields integration that made it easy for anyone at the school to make sure that the information was up-to-date and relevant.\"), mdx(\"div\", {\n    \"className\": \"image-container large-image\"\n  }, \"\\n  \", mdx(\"span\", {\n    parentName: \"div\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"1200px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/c84c92c7b7faf463f757a17a1a460f46/6a5c3/lawton-academy-capture.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"88.33333333333333%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAAsTAAALEwEAmpwYAAADpElEQVQ4y3WTW2gcVRjH8yT4IvTJJ5/6YKWmGKvGqqQGtYiK6Q1KoMRiXwRRIUUpgUTFYr21RkNUULyk8QLSCFLqjcSCbQm11ly7m2z2vjM7s9nd7M7uTGZ3Z+fnN7NpbtgDf86Z+c75n+/7n//XlHXgurLIpakg18JJNBvSy66ANdhs/PbiK/tUgWLWufZPgHNDIzTlXPg3kmLk9z8589M5kqWqT6ot19Fls267aFbdn9dAI1ZpzBmZtapcIMk1pS2XlJBMRVVmEjpp/zDklh0WSzaZcoVUtojurUvLApusVUM3LH+PVjTJmFVUyTJtOjQ5dZdqzcEomz4KRYOCUSKbL1BxJP2V4a6bN8MbQkOtXqfJ+6hUKszPzxNeWCAajhCLxYiEw/6cSCQESRRFIR5PkEw21qqaJiWzoqqkUgoV2/aJfcJqrUZCUUlkMkQzOuF4nHhKpVAoYpomuVwOJa1RLBbIZrNCHPdJlVRKyFLE5WIvqVXCghw4P/QZox+eJvjJFyyM/8X4L2cZ/vpz+k9/wNhvoyRmpvn+zA9cvnjJP1gUWUoikV2prknhug3CqJR6qHU7r+xs5p0dLRx+vJ2n7t3Bli23cfutt/Bo60MMn/2ZbW3P0v1aH3XRamJykkAw6EsViUY3ZljMpOnt2sv25rvZ3XoXT99zBx177uSFgw9wdM+DHHjsPl7u7qXjwH4GvvyKarXK9PQ0oVBoReMENZFtlTAYCLL3kWbe6tnPka5BujpGOPTit7x0rI83jr/PyVdP8OM3Azy3r5/vLujUa5ZkFSMjeut6A47jrBHOh5Zoe+IPOo+meOZ5eLijyq52ja0to2zdNUhL+6/c3/ou23Ze4b2PF2k8ZJ3NY03DhM2TB69y+MhV9nWeom13JyeODdF/aoyPXh/g0zffZrCnh+GTx5m9eN4/XHPq/qOUTQvPyx5WM7TF2HOZRRJ5nVBG47qqifPL5KsG2YqBbi6RNvIkC0vkLathZCGoiJaedt667q4jdJwaRrGIZS5vKMEsW+K9Eu6m6jyi/+scbpRsWQ2RF8W0uVye/NKSlOCVVCYqpvU6IS8Xjo1fJiQ2yeXzvsHLYnrbMDA1zbfSaoaeh/KyySP2OsODNwzZPDU1xYxYZHZujr7ebi6I4VXpmsmJCWZmZ1Ekpl/5G2d963mv492wHjcII5EISWkvVVXQYmFss+S3XiAQYEH6PS0xQ7JdfWXXdbnZuFnM++/HVuLrNfwPoTn+ioaFMUkAAAAASUVORK5CYII=')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"The Lawton Academy Website\",\n    \"title\": \"The Lawton Academy Website\",\n    \"src\": \"/static/c84c92c7b7faf463f757a17a1a460f46/c1b63/lawton-academy-capture.png\",\n    \"srcSet\": [\"/static/c84c92c7b7faf463f757a17a1a460f46/5a46d/lawton-academy-capture.png 300w\", \"/static/c84c92c7b7faf463f757a17a1a460f46/0a47e/lawton-academy-capture.png 600w\", \"/static/c84c92c7b7faf463f757a17a1a460f46/c1b63/lawton-academy-capture.png 1200w\", \"/static/c84c92c7b7faf463f757a17a1a460f46/6a5c3/lawton-academy-capture.png 1646w\"],\n    \"sizes\": \"(max-width: 1200px) 100vw, 1200px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\"\n  }), \"\\n  \"), \"\\n    \"), \"\\n  \", mdx(\"a\", {\n    parentName: \"div\",\n    \"href\": \"http://lawtonacademy.com/\",\n    \"target\": \"_new\",\n    \"className\": \"image-caption\"\n  }, \"The Lawton Academy Website\")));\n}\n;\nMDXContent.isMDXComponent = true;"},"next":{"id":"6f52c710-a364-5197-ab08-77f878db0195","fields":{"slug":"/automating-donations-ifttt/"},"frontmatter":{"title":"Automating Donations with IFTTT and Qapital"},"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Automating Donations with IFTTT and Qapital\",\n  \"date\": \"2017-02-07T00:00:00-0500\",\n  \"teaser\": \"Automatically put money towards a donation every time something gets mentioned in the news.\",\n  \"featuredImage\": \"iftttDonationsScreenshot.jpg\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"One of the great trends that has come out of the past few years of technological advancement is the move towards simplifying previously complex tasks for folks who don\\u2019t want to write code. This simplification opens the door for people to use technology in new and inventive ways, spanning from DIY home automation all the way over to activism. I\\u2019d like to touch a bit on the activism side today.\"), mdx(\"p\", null, \"Supporting organizations like the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://aclu.org\"\n  }, \"ACLU\"), \" or the \", mdx(\"a\", {\n    parentName: \"p\",\n    \"href\": \"https://splc.org\"\n  }, \"Souther Poverty Law Center\"), \" has been at the top of my list for quite some time, but actually donating always depended on me going to the site and filling out the form when I wanted to provide financial support. A recent conversation about donating every time something gets mentioned in the news spurred me to look for automation alternatives for this task.\"), mdx(\"div\", {\n    \"className\": \"image-container large-image\"\n  }, \"\\n  \", mdx(\"span\", {\n    parentName: \"div\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"640px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/eeb9720670f18ad5ca5f033d494cf27a/c08c5/iftttDonationsScreenshot.jpg\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"75%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAMEAQL/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAABaujiJTCv/8QAGBAAAwEBAAAAAAAAAAAAAAAAAAERAiH/2gAIAQEAAQUCgxo6Q0o//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFhAAAwAAAAAAAAAAAAAAAAAAABEg/9oACAEBAAY/ApR//8QAGhABAAIDAQAAAAAAAAAAAAAAAQARITFxYf/aAAgBAQABPyFZV6iCy9QVvDFD5UcTk5Kf/9oADAMBAAIAAwAAABA4D//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAECAQE/EGf/xAAbEAEAAwEBAQEAAAAAAAAAAAABABEhMUFRYf/aAAgBAQABPxBwXVxoyWJoYfT7cqww6QiiW8m08l+tJj0/YjAGlNcn/9k=')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"Photo by 401(K) 2012\",\n    \"title\": \"Photo by 401(K) 2012\",\n    \"src\": \"/static/eeb9720670f18ad5ca5f033d494cf27a/c08c5/iftttDonationsScreenshot.jpg\",\n    \"srcSet\": [\"/static/eeb9720670f18ad5ca5f033d494cf27a/f93b5/iftttDonationsScreenshot.jpg 300w\", \"/static/eeb9720670f18ad5ca5f033d494cf27a/b4294/iftttDonationsScreenshot.jpg 600w\", \"/static/eeb9720670f18ad5ca5f033d494cf27a/c08c5/iftttDonationsScreenshot.jpg 640w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\"\n  }), \"\\n  \"), \"\\n    \"), \"\\n  \", mdx(\"a\", {\n    parentName: \"div\",\n    \"href\": \"https://www.flickr.com/photos/68751915@N05/6281020696/in/photolist-az2SCh-bn4oq2-d3koK-7xFCXW-5QKWwC-aFAPtx-7xFvR7-fBsQs-f9ZEG-62QVKf-713m5r-659Rgz-aFDgrH-ad9aU-nTZJp-bjoEy4-ebifU-kyBTGB-fdHEa-6TjBCF-QxcaH-5FPV63-donZN-2abVs-s6895e-biaRHp-snzBqK-s4fksR-s61m4j-s61ncG-JCQG88-cNdyo-bu6pKh-s5ZdWJ-bu6sBd-snzAJp-s61ku3-skhAfL-smQwn4-rqLAHi-s688Fi-s684tk-pYSVGy-snzzza-snxbdk-s685Wv-vFBXwb-chEejy-aYWfHD-aFDkRt\",\n    \"target\": \"_new\",\n    \"className\": \"image-caption\"\n  }, \"Photo by 401(K) 2012\")), mdx(\"p\", null, \"I wanted something that didn\\u2019t require a lot of overhead to run, and something that could be easily updated as-needed. The obvious choice was to use IFTTT (If This Then That)\\u2013a plug-and-play service that drastically simplifies trigger-based actions.\"), mdx(\"h3\", null, \"You\\u2019ll need a few things to get started\"), mdx(\"p\", null, \"First things first, you\\u2019ll need a free IFTTT account to get up and rolling. Head over to \", mdx(\"a\", {\n    href: \"https://ifttt.com/join\",\n    target: \"_new\"\n  }, \"ifttt.com/join\"), \" to sign up. Once you\\u2019re signed up, you\\u2019re ready to create your first applet. \\u201CWait, applet sounds pretty \\u2018code-y\\u2019, and you said no code!\\u201D Regardless of the name, there is still no code involved in this\\u2013an applet is just a collection of actions that you want to take based on some event happening. What that event is listening for is up to you, and you have a ton of services that can tie into IFTTT that will help you create yours. Some fun examples are having \", mdx(\"a\", {\n    href: \"https://ifttt.com/applets/24908p-text-me-the-weather-every-morning\",\n    target: \"_new\"\n  }, \"IFTTT text you the weather on your way out every morning\"), \", or having \", mdx(\"a\", {\n    href: \"https://ifttt.com/applets/152298p-get-an-email-whenever-the-u-s-president-signs-a-bill-into-law\",\n    target: \"_new\"\n  }, \"ProPublica send you an e-mail every time the President signs a bill into law\"), \".\"), mdx(\"div\", {\n    \"className\": \"image-container half-image\"\n  }, \"\\n  \", mdx(\"div\", {\n    parentName: \"div\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"div\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"406px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/036cbe6b77145b251543fe524ac753a1/e33ef/iftttWeather.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"148.33333333333334%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEcElEQVRIx5VW2U5bVxR1XyqlUWMMHq/nEQ+AgQI2nm3AxiOGEAgByhySAI1CSKiiDmkfKlVtpaaqWvU3+gv5j/zK6t77cokNTtI8bN3je/ZdZ+21h2Pd+dcvUKk20F5axkL7tmqLF9b+f7Z4+w7mKlX8/uoP6CYTKfQZTLApTlisdlhtDlgsNphpbbY6Lp7vN5vdhRs39Wi1l6DLF2ZgJjCHPwiHNwCr3QclPAZPcBBujx9uevch8wUGMWCy4u7aBnSpfBF+YpXwBjHsCWBmwo3xlTVYJ+twOVxwEqjrA+bxBWEYMGPl7j3opgkwTKH9G4nidSmONz/E8fPzJD5r/wSv1w+n2/dxgHkC1JMO59EI/iwN4ZtqCM9flBDb2IJDcXV9+C7wLsAsAbKwCm0orKGLNPF5EfI64SIZrurVC7QLMJMrSpb4JQtrJOPs9psU+a1l0mi2wWRRLpl2AndrmM5iMDKEb797iVV6cXD/gaR/7d4G1tY3UZqt4MnpGU6fPqN6rQtLBuiUoGfIXNiPjk6wt39finR1bV3A640FWR+dPKYD19FvtAhbu9NzCdoFmMrk4A+GsU5JaLTaqNVb2Ds4xDEBcAdUa02ks3lU603UGi0BZfbRofgl6BXAvBTmg0fHOHx4JCy3d/axubWDs2fnaC4sotFs4+TxExwdf4V9Ouz7lz8iMZ2GlRpCk+Aa4MbmlrDgjznEzS+3hVF7cVk07us3UaiKhNuZlGshT6eyiMRGRPhd0o8ZMMuDw4fY2t7FX3//g1yhJJnXysbu8r4nKVQ2TJ03FIcbDnJmR35yOQ2NjIpegVCEmMYQjg4hFI6+u2xYcD65UJrFdDonbObKVeTyJYxPJMBJK5Tm5FmcKaNIa/bjhDABxeHpDcg1li/OgqdPlsDSpK0KMke1WAZHkiR58sUZMa4G9ivP1zAy+gVuGYxSx9QpBTkpEhuW0KZoPsbHJmQdHIyooYZjEi4nj/UO0W/NOGFcdtcYTiXTGB2fBGc9MZ0BdxCDabpyiNrzqnl8AQK0dHeKlsHOclBFD3zc+GJACw1Y3lBPdHeYRzLNLJ1uLzFUWapM3/r07OW3zh4qI7pXbDxlFAHi9ed6A/WxmQrcCL1hQN5pxj4S8qoAlmQs8UstBD6ZQRkgRVpu7+xhifqaM16p1qjHl4m1S8DYj/17MtQ0tNmdlwzZOZnKyIAYjo/ROo1EMgXlwoeNv+3qFNaQgdRCdQmgZtxFAyaLsDXR9cprNm1fIY05oQKohcyA2tDkzatZ7HV1du6pdXhRNtwRRrNVssknahf39Yy7JQJmrBn7M2seunrqlOU7q+oVwOEMx0epM8LUv1N0ql+06Q5dFT8QGhS/YCgML/05yOTyNOq28OmNm1heIcD46Dhu9fWL8L5AEBNTSQrFJ2ViGDBJmXSWijp9uE1HCDxMvV+iKtiFTvcJ6s0WdKdPzzAzV5bxX603aF3BfK1Od0mLBmyzw1qyX6b7Rmy+KoNhtlyhcpoV++XX3/Afcyyliu38aKcAAAAASUVORK5CYII=')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"Weather Applet\",\n    \"title\": \"Weather Applet\",\n    \"src\": \"/static/036cbe6b77145b251543fe524ac753a1/e33ef/iftttWeather.png\",\n    \"srcSet\": [\"/static/036cbe6b77145b251543fe524ac753a1/5a46d/iftttWeather.png 300w\", \"/static/036cbe6b77145b251543fe524ac753a1/e33ef/iftttWeather.png 406w\"],\n    \"sizes\": \"(max-width: 406px) 100vw, 406px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\"\n  }), \"\\n  \"), \"\\n    \"), \"\\n    \", mdx(\"a\", {\n    parentName: \"div\",\n    \"href\": \"https://ifttt.com/applets/24908p-text-me-the-weather-every-morning\",\n    \"target\": \"_new\",\n    \"className\": \"image-caption\"\n  }, \"Weather Applet\"), \"\\n  \"), \"\\n  \", mdx(\"div\", {\n    parentName: \"div\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"div\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"407px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/1e46edc025702a42f4aa6d202a0c8589/0ff56/iftttProPublica.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"159.33333333333334%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAgCAYAAAASYli2AAAACXBIWXMAAAsTAAALEwEAmpwYAAAFqElEQVRIx5VViW/TZRiuBoNRro2t5wYIkaFAEJkcAxnQ3Wt3sa3bYAfbunZj3d3uaHd2WxmMbYyxewwBuQaEIMihENBEiaKAxqDiiMaExMR/AR/f92s7WhDUJk++4/d9z/e8ZyX145cRZh5CdO0oompGEFE9LEaG1nbwPyG+fhxbqgYxdOFLSEJK+jBTa8XbuXuwKNOB5fmdCMrpEPBNaIAPwT0+D/5JjXg5zIzMXcch2Vw5KC5fvHUfV2//hCtf/4jHj//CxM17kG5twrz0VgSmvRgLMtowS2uDofs0JBtKD2BVYQ/uTT7CzXuT+Oy7hzjyyW1Uj1wUhCqd/V/Bj87Q1EHfNQHJejJ5fWkfvvjhVxy89BWu33kg5te+fSAOKlNb/h8h+/D9sgP4/PuHOHnjLvh3/7c/SOmkMMdN6En89CNehEz2rrEbN+7+gm9+/h2Tj/7E8et3xFqR0uLlK77Me0+TehGGW4YwJ65eRJkvcdTkKc3wo8hx9Hzi62mvHrPjbGJvPgXgHxXGughDK/qxOLsDjYeuoKDrNHb2noXGOoaSvnMItwxju+MYCvedQe6ek2KvvP88PdSEABeZgsi9FHJC8osxdaPYQZeYZHPlANJaj+Kdgi4kNByCms6kthxBzu4T2Fjej1mklgnZEiYLSLN7E/JL+XtPoW70Y2RRcm5rPybABKwwv/OUIGKFtoOX6JFx6PdOiDO1dIdj8Gp0rbBwSmE+HWA1MVSCfIEVpTQfFqXIF5fm7UEEqU9v+xChRL6BUo1Htmydaf8TQt7kSnEcu4YMOswK80hR6YFzMA9dEMp5HVs3RuuPoLMfFXv8YCz5+r2ifSJYXL7CZPbXgm3torj5El9Odinb2vQB0smX7Ndgush+tY5dEvuJjYdEA2F1bOEMjYuQfcPmNB2+ihoqt8KeM4KQS69i4LwgLtp3Fkbaz+44jkAKAqfS3MRGocxZ7214PfapoLhf5NpmcEtiJat39iLSpZbPyJObKbmbRYJzlJ/JQzX1Qk7gJTm78QaZHkQ5uXC7g9Au8pNb2lJKenYLJ/VKQxeW5XWSVZ1iFFXkmYfqqiEhO6RkP7iu2VccTS5JbhqrjD3OOX3jrrSavnMggmkeQv5zt7cpH3LSsnS+xA5eQcm8trhXEKw0dIvLmyoGhBt4vpHOMRmLkJH5SnelxHoo5A9cy2/t2O00h+ZLuGuTyWwmVwKD/eWctz6/2wiFRMhlxmRsEvtpFWU/7y0k33EQVKRE+Rx4EfIfFHcTZSrVJkEmouecM5Q6UpP2YniZzIS+lFMBuhYoEmqgiLMQzK7RApnWDDmv451rMRLkcRbnfkKtS6HVg5AV8sdEKxRJNkgjiuCv1sOPoIoqgjTMgDmhufDdnA+fTXkC/uoC+IcViHMqemCGxiYahiSMUsRHWwMlqVOltwvI46shCyeSTXqsyWlAvn0EqTW92GJsg7a8E0nmbsgiCuEfbhSPKaJNVCm1boXD8I23kcIqKJMboaQAyKJMLoUFUEQYsSKtmmDB4sRyLEs1Y1lKlXhQqKRzSm2F0+S9Hj5UJVPr11ZBrqmALLoUshgnpDT3DS+Gb0Qx/CJNYmS4v8vofKCuxYOQTJ6b2ITADDaXco7AoyrtCQLIDc/CeS4ww4EF23cJHzobbEkXZkeWiYhJNZXwiSqjsUqs5VoP0FpGFvjHVk5BSpgTWUoow2tqE/Ich4nQYBcRXK4zCx+F6puxUFtCznb6T04QI/ksILoIQUnlU3gzoQxqox26mh5MW70NevswJMGZVrwUnIGlqRYExBSD134UuWlrMjE9JBvT12URsvHK2izM3JiL+ZoSBMaYME9jgpSirC5sQ1bDACRB8ciw9kGy/8Rl7GgexM6OcRjaR8W8oG0UhY4xGNsJHqOBRn3ryBT4XHbjABH2I6dpEBOf3sLfGBdpcTqymjoAAAAASUVORK5CYII=')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"ProPublica Applet\",\n    \"title\": \"ProPublica Applet\",\n    \"src\": \"/static/1e46edc025702a42f4aa6d202a0c8589/0ff56/iftttProPublica.png\",\n    \"srcSet\": [\"/static/1e46edc025702a42f4aa6d202a0c8589/5a46d/iftttProPublica.png 300w\", \"/static/1e46edc025702a42f4aa6d202a0c8589/0ff56/iftttProPublica.png 407w\"],\n    \"sizes\": \"(max-width: 407px) 100vw, 407px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\"\n  }), \"\\n  \"), \"\\n    \"), \"\\n    \", mdx(\"a\", {\n    parentName: \"div\",\n    \"href\": \"https://ifttt.com/applets/152298p-get-an-email-whenever-the-u-s-president-signs-a-bill-into-law\",\n    \"target\": \"_new\",\n    \"className\": \"image-caption\"\n  }, \"ProPublica Applet\"), \"\\n  \")), mdx(\"p\", null, \"The next part that you\\u2019ll need is a \", mdx(\"a\", {\n    href: \"https://www.qapital.com/\",\n    target: \"_new\"\n  }, \"Qapital\"), \" account, which you\\u2019ll need to sign up for via your smartphone. Qapital is a very similar service to IFTTT, but it integrates with your bank account to help automate your savings. I have an applet running on there than automatically rounds up to the nearest dollar for every one of my debit card purchases, and then puts that money  into a vacation savings account. Once you\\u2019ve set up a Qapital account, you\\u2019ll need to connect your bank account to it. This will be the account that it draws out of to put money towards your donation.\"), mdx(\"h4\", null, \"Creating a donation Qapital goal\"), mdx(\"p\", null, \"Now that you\\u2019re up and running on Qapital, you\\u2019ll need to set up a goal for your target donation. I started with $50 towards the ACLU, but you can do this for any cause or savings goal. This is probably a good time to point out that you don\\u2019t have to use this for donation purposes\\u2013this would also be great if you\\u2019re just trying to control your savings a little more.\"), mdx(\"h4\", null, \"Connect IFTTT to Qapital\"), mdx(\"p\", null, \"Jump back over to IFTTT, and then go to the \", mdx(\"a\", {\n    href: \"https://ifttt.com/qapital\",\n    target: \"_new\"\n  }, \"Qapital Service page on IFTTT\"), \". Click connect, and then log in with your Qapital account. Just like that, you\\u2019re ready to create your first applet with Qapital and IFTTT.\"), mdx(\"h4\", null, \"Find your news source\"), mdx(\"p\", null, \"We need a concise text-based source to \\u201Clisten\\u201D to in order for this applet to run. I chose to use the \", mdx(\"a\", {\n    href: \"http://rss.cnn.com/rss/cnn_allpolitics.rss\",\n    target: \"new\"\n  }, \"RSS feed from CNN Politics\"), \". We\\u2019ll stick with RSS feeds for this tutorial\\u2013keep in mind that you can use any RSS feed you find. What we\\u2019ll be doing is listening for a specific word in the feed that will trigger our applet to run. Once you\\u2019ve found your RSS feed, head back over to input your feed\\u2019s details in IFTTT.\"), mdx(\"h4\", null, \"Creating your first applet\"), mdx(\"div\", {\n    className: \"paragraph-with-picture\"\n  }, mdx(\"p\", null, \"Click \", mdx(\"a\", {\n    href: \"https://ifttt.com/create\",\n    target: \"_new\"\n  }, \"New Applet\"), \" on IFTTT to start building your first applet. The formula is as simple as the name\\u2013if \\\"this,\\\" then \\\"that.\\\" For the \\\"this\\\" side, we'll be using IFTTT's RSS service. Click \\\"this\\\" and select the orange \\\"feed\\\" icon. We're listening for a word, so select \\\"New feed item matches.\\\" Here, you'll input whatever word you want to listen for, and the link to the RSS feed that it will pull from. Keep in mind that this will only be looking at the headline and a quick intro to the story, so you'll want to keep your trigger word short and specific.\"), mdx(\"div\", {\n    \"className\": \"image-container small-image\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"div\",\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"359px\"\n    }\n  }, \"\\n      \", mdx(\"a\", {\n    parentName: \"span\",\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/28276ff97dda755bc284a2f2c3553ce0/f5eb6/iftttFeedIcon.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }, \"\\n    \", mdx(\"span\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"99.66666666666667%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAACGElEQVQ4y2N4V8rwHxm/LcHOJhYzYDeQ8f+7cpb/78qYIWwSDGfAZtjbAob/b7KAOAcoVggUK2MCYkaiDEVzIcSwT7Nc/3/b0/T/88KA/++bxP+/zYUZzAw2FJ/BqAaWM/9/k83w//uh/v8w8O/Pz/8/Tsz4/75ZCmwwIUMxw7CY4f/7RtH/H6dY/v+6pfj/n9e3IQZ///D/0xwPFEOJ8zLQax+nWP3/sirx/4dWWTD/y9o0uIsJGYrdywe64Qb8vLQaHCGfptvDXfq+RQoSptAUQNDLH9oU/n9eHPL/142tYEP+vLsPlvu6LhPMB4UpzJXEJZtciMEg+tvWMohLLywHu+rPm7v///3+AYx9CayuRHUhML29zQclG2ew136cnvf/LTAt/rq5A2woKAl921YOZn+e74vVlWgGMoMT89eN+WBNfz8+/f82Dxgpy2PA/C8rE4CWuYDZ3/a2gsMbv4HQMHxXyf7/y5rU/x8nGoMNBMX2t10N/z9OMAQnqW87a/9/mmZL2MuwZAAyFGQ7PCyBGt+kM4ANB2fLTAZw0IDDu4SYwgEUlqDY7tECusoI6GKO/+9qeICuE///oVMVoqacmHSIHDl5DODw+rI66f+37ZXAcM0D05/neYPlwAVGKbEGwlwKKsKA+H298P/3tfz/3zeI/H9XxQUJZ2LLQ5SwhBYCb4ugYQml8ZWP+F1IhhwDqUU8IQwAAgr+jOYJqckAAAAASUVORK5CYII=')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  }), \"\\n  \", mdx(\"img\", {\n    parentName: \"a\",\n    \"className\": \"gatsby-resp-image-image\",\n    \"alt\": \"IFTTT Feed Icon\",\n    \"title\": \"IFTTT Feed Icon\",\n    \"src\": \"/static/28276ff97dda755bc284a2f2c3553ce0/f5eb6/iftttFeedIcon.png\",\n    \"srcSet\": [\"/static/28276ff97dda755bc284a2f2c3553ce0/5a46d/iftttFeedIcon.png 300w\", \"/static/28276ff97dda755bc284a2f2c3553ce0/f5eb6/iftttFeedIcon.png 359w\"],\n    \"sizes\": \"(max-width: 359px) 100vw, 359px\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    },\n    \"loading\": \"lazy\"\n  }), \"\\n  \"), \"\\n    \"), \"\\n    \", mdx(\"a\", {\n    parentName: \"div\",\n    \"className\": \"image-caption\"\n  }, \"IFTTT Feed Icon\"), \"\\n  \")), mdx(\"p\", null, \"Now that you\\u2019ve got the \\u201Cthis\\u201D side down, we\\u2019ll tackle the \\u201Cthat\\u201D side. Click on \\u201Cthat\\u201D and choose your Qapital service. Since this is on the action side, we only have one action available\\u2013save towards a goal. This will pull in your list of goals from Qapital. Choose the goal that you set up to save towards your donation. You can choose how much you\\u2019d like to save towards your goal every time the applet runs.\"), mdx(\"p\", null, \"$1 is a great place to start out if you\\u2019re concerned about this getting out of hand, but remember, the applet will only run until you hit the goal that you set in Qapital. For instace, if you set a $10 goal of saving a dollar towards a donation to the \", mdx(\"a\", {\n    href: \"http://www.ctunet.com/\",\n    target: \"_new\"\n  }, \"Chicago Teachers Union\"), \" every time Betsy DeVos gets mentioned in the news, you would quickly hit your limit on a high-traffic day like today, when she was successfuly appointed by the Senate. No need to worry, though, once you hit your goal, your applet will stop running automatically.\"), mdx(\"h3\", null, \"Now actually donate the money\"), mdx(\"p\", null, \"Automation like this is great because it never sleeps or misses an important news story. Unfortunately, we still have one human-involved step in this process to get the money to the place that you\\u2019d like to donate. Once you reach your goal in Qapital, you\\u2019ll need to transfer the money over to your bank account and then actually make the donation yourself. This definitely isn\\u2019t ideal, but it\\u2019s a step in the right direction to regularly donating.\"), mdx(\"h4\", null, \"Next steps and improvements\"), mdx(\"p\", null, \"I\\u2019d love to see a way for IFTTT to automatically make that donation for you, but as of now I haven\\u2019t found a way to do that. Qapital is a great service to build your savings, but the money does sit in a Well Fargo account until you actively move it out. The upside of this is that your savings are FDIC-insured, the downside is that it\\u2019s through \", mdx(\"a\", {\n    href: \"https://en.wikipedia.org/wiki/Wells_Fargo#Controversies\",\n    target: \"_new\"\n  }, \"Wells Fargo, a historically shady bank\"), \". Because of this, I would suggest moving the money out ASAP after you\\u2019ve hit your goal. This can also be aided by setting smaller goals and donating more frequently. Qapital makes their money by keeping your funds in that account and accruing interest on them while it\\u2019s there, so really it\\u2019s in your best interest (har har) to move it to your own interest-accruing account frequently. The tricky bit is that they won\\u2019t let you transfer until you\\u2019ve hit your goal\\u2013if you decide that you want to move the money before you\\u2019ve reached your goal, you can edit the goal to match whatever amount you have in the account, and then go ahead and transfer it. Is it perfect? No. Is it a step in the right direction? I hope so.\"));\n}\n;\nMDXContent.isMDXComponent = true;"}}},"staticQueryHashes":["3128451518"]}