<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Axel Pettersson on Medium]]></title>
        <description><![CDATA[Stories by Axel Pettersson on Medium]]></description>
        <link>https://medium.com/@axel-84042?source=rss-b7ad7c659911------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*WLDKwNJ01ODpRz8IvXd6lg.jpeg</url>
            <title>Stories by Axel Pettersson on Medium</title>
            <link>https://medium.com/@axel-84042?source=rss-b7ad7c659911------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:02:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@axel-84042/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Going serverless on Heroku using one-off dynos]]></title>
            <link>https://axel-84042.medium.com/going-serverless-on-heroku-using-one-off-dynos-79b6fd85705a?source=rss-b7ad7c659911------2</link>
            <guid isPermaLink="false">https://medium.com/p/79b6fd85705a</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[demo]]></category>
            <dc:creator><![CDATA[Axel Pettersson]]></dc:creator>
            <pubDate>Mon, 12 Apr 2021 10:40:59 GMT</pubDate>
            <atom:updated>2021-04-13T14:26:54.026Z</atom:updated>
            <content:encoded><![CDATA[<p>My classmate and I investigated the possibilities of using Heroku for deploying serverless functions for a DevOps course at KTH in Sweden.</p><h3>Introduction</h3><p>The usual use of Heroku is to have some arbitrary program running inside a Heroku “dyno”. A dyno is a virtualised Linux container that is aimed to run user-written code. The most common use of these dynos is to deploy web services, that aim to be up and running at any given time. However, if a developer wishes to provide a simple program that does not require a dyno to be active at all time, the regular Heroku dyno approach may become inefficient and costly. However, Heroku offers something called “<a href="https://devcenter.heroku.com/articles/one-off-dynos">one-off dynos</a>”, a special set of dynos that are aimed to perform a specific task and terminate the dyno when complete, we quickly realised that these dynos could be used to implement serverless computing in your Heroku app.</p><h3>Requirements</h3><p>The requirements for our initiative was quite simple, we wanted to have some arbitrary program up on Heroku and through HTTP requests be able to run this program and pass parameters to it. When this program is not running, no dyno for this Heroku app should be alive.</p><h3>Results</h3><p>We successfully managed to deploy a simple Heroku app that takes environment variables as inputa and is run within a one-off dyno when requested. To invoke the dyno, we created a simple frontend application that communicates with the <a href="https://devcenter.heroku.com/categories/platform-api">Heroku Platform API</a>. It takes input parameters for the Heroku app, a command to be run in a one-off dyno (which is specified in your Procfile), a Heroku API key that has write access to your project, as well as arbitrary environment variables, which are used to send parameters to your program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*JT0iJtRJ5Vsmz4Tet5IRbA.gif" /><figcaption>Demo of the frontend application</figcaption></figure><h3>Tutorial and code</h3><p>If you want to learn more about how we went about implementing this, be sure to check out the tutorial where we also present the code for our Heroku program and the frontend, which can be found along the source code in the GitHub repository here: <a href="https://github.com/felix-seifert/serverless-on-heroku">felix-seifert/serverless-on-heroku: Function-as-a-Service tutorial for Heroku (github.com)</a></p><p>Also, if you’re interested in using the frontend to invoke your serverless functions, feel free to do this here: <a href="https://felix-seifert.github.io/serverless-on-heroku/frontend/">Serverless on Heroku — Frontend (felix-seifert.github.io)</a>. All of the inputs to Heroku are controlled by input fields. We do not store any of the data you input in the application.</p><p>Thanks for reading! If you have any questions or other ideas regarding our approach, feel free to share them in the comments or create an issue on the repository.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79b6fd85705a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a React Native app with Wordpress backend]]></title>
            <link>https://medium.com/swlh/creating-a-react-native-app-with-wordpress-backend-b56f8dc1d21c?source=rss-b7ad7c659911------2</link>
            <guid isPermaLink="false">https://medium.com/p/b56f8dc1d21c</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[blog-app]]></category>
            <dc:creator><![CDATA[Axel Pettersson]]></dc:creator>
            <pubDate>Mon, 19 Aug 2019 12:13:45 GMT</pubDate>
            <atom:updated>2019-08-21T07:55:24.566Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pGTVzQBNjQm7gQw4QIAohA.png" /></figure><p>First, let us begin with a bit of a backstory. As a consultant who mainly does web and app development, React Native and Wordpress are some of the most used tools I use for my products, and when a customer of mine wanted an iOS/Android app with a blog-like behavior, I got the idea of combining these two tools to create the application.</p><p>So, why Wordpress you might ask? Well, for starters it is a CMS that many people are used to because of its wide usage. And due to its integrated <a href="https://developer.wordpress.org/rest-api/">REST API</a>, we can fetch, edit, and delete data from within our app through a simple HTTP request.</p><h4><strong>Prerequisites</strong></h4><ul><li>A working <a href="https://wordpress.org/">Wordpress</a> instance on a domain with some content you want to display within the app.</li><li>A <a href="https://facebook.github.io/react-native/">React Native</a> app with <a href="http://react-native-config/">react-native-config</a> (for storing the API-URL and credentials) and <a href="https://github.com/eranbo/react-native-base64">react-native-base64</a> (only if you intend to update the data on Wordpress through your app).</li></ul><h3>Part 1. Fetching data from the Rest API</h3><p>First things first, let us add our API-URL to our <em>.env</em> file in our <em>React Native app. </em>Notice that the Wordpress REST API is located in the <em>/wp-json/v2/</em> directory of your domain:</p><p><em>.env</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf934aae61c5551e228804c257a64703/href">https://medium.com/media/bf934aae61c5551e228804c257a64703/href</a></iframe><p>Now let us create a file called <em>api.js </em>where all of the API-related functions will be written in. Place it wherever you want but for this tutorial, I will place it in the <em>/src/lib</em> directory.</p><p>Our first function will be used to fetch the data from the API, it will take an argument which contains the route to our endpoint we are trying to reach. For fetching the data we will use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API">Fetch API</a> provided by React Native.</p><p><em>api.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1d24df8ed6e65414f5c7dc5737e0c92/href">https://medium.com/media/c1d24df8ed6e65414f5c7dc5737e0c92/href</a></iframe><p>Let us create a React Native Component in <em>src/containers/Posts </em>which fetches all of our posts. Because we don’t want to load all of the posts at once we will make the component only load 10 posts at a time and load more once we have scrolled through all of the loaded ones.</p><p>The route for fetching our posts are <em>/posts</em>, for this component we will use the arguments <em>per_page</em> and <em>page</em> in our API request, a full list of arguments can be found <a href="https://developer.wordpress.org/rest-api/reference/posts/#arguments">here</a>.</p><p><em>Posts.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baa5b0d239edc560a45696df452c8d3a/href">https://medium.com/media/baa5b0d239edc560a45696df452c8d3a/href</a></iframe><p>We use FlatList for the rendering of our posts, and due to this, we can pass an <em>onScroll</em> function which we can use with our custom <em>isCloseToBottom</em> function to detect whether we should load more posts or not. Each item we are rendering is wrapped inside a <em>TouchableOpacity</em> which when pressed navigate you to the <em>Post</em> container with the Wordpress post id, which we can use inside of that container to render the specific post.</p><h3>Part 2. Sending data to Wordpress through the API</h3><p>So, maybe you want to be able for the app to be able to send data to Wordpress through the API, this could be useful for community interaction or admin functionality through the app. Luckily, the Wordpress support POST-request for creating and updating data on your Wordpress database.</p><p>For this example, we will use <a href="https://github.com/WP-API/Basic-Auth">Basic-Auth</a> handler by Wordpress to be able to authenticate, this allows us to send a post request containing the base64 encoded username and password of an account. For this to work, you need to have a service account on your Wordpress website that has the capabilities to edit/add content.</p><p><strong>Important: </strong>for production, it would be preferred to use OAuth or similar authentication method due to the Basic-Auth requires you to send base64 encoded credentials in every request.</p><p>When we have our service account setup, we specify our credentials in our <em>.env</em> file.</p><p><em>.env</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7e74c82b937cc8c63f170163ff06e30/href">https://medium.com/media/e7e74c82b937cc8c63f170163ff06e30/href</a></iframe><p>Now in our <em>api.js </em>file, we can write a function which can update and add data using POST<em>-</em>requests.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54469613939c801f603c510ea1cb987a/href">https://medium.com/media/54469613939c801f603c510ea1cb987a/href</a></iframe><p>We need to encode our service account’s username and password and send it with the Authorization header to be able to make the request, this we achieve with <em>react-native-base64</em>.</p><p>Our function takes two arguments, a route and the data we want to update/add. As an example, if we want to update a post with the id 5 with the new title “<em>Hello World</em>” our route would be <em>/posts?id=5</em> and our data would be { title: “Hello World” }.</p><p>With these steps, we can now create a simple blog/news based application using React Native and Wordpress! If you want to make more advanced queries using through the Wordpress API you can take a further look into their <a href="https://developer.wordpress.org/rest-api/extending-the-rest-api/">API documentation</a>.</p><p>Thanks for reading! If you have any questions or interesting ideas/improvements, feel free to share it in the comment section below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b56f8dc1d21c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/creating-a-react-native-app-with-wordpress-backend-b56f8dc1d21c">Creating a React Native app with Wordpress backend</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>