<?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 Nadun Yashmika on Medium]]></title>
        <description><![CDATA[Stories by Nadun Yashmika on Medium]]></description>
        <link>https://medium.com/@naduns?source=rss-926fa31733db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C38YqwE0EH8eZ9TIRkZEKw.jpeg</url>
            <title>Stories by Nadun Yashmika on Medium</title>
            <link>https://medium.com/@naduns?source=rss-926fa31733db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:04:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@naduns/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[How  to  Create  a  Serverless  API  and  use  it  with  React  app]]></title>
            <link>https://medium.com/the-ai-team/how-to-create-a-serverless-api-and-use-it-with-react-app-d08ae7bf05ae?source=rss-926fa31733db------2</link>
            <guid isPermaLink="false">https://medium.com/p/d08ae7bf05ae</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Nadun Yashmika]]></dc:creator>
            <pubDate>Mon, 13 Jan 2020 13:45:01 GMT</pubDate>
            <atom:updated>2020-01-13T14:18:41.348Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Create a Serverless API and use it with React app</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*b67Ble7aouitXUow.png" /></figure><h4>What is Serverless?</h4><p>Traditionally, we deploy applications to a server where we handle all the requests and responses. This method costs more than resources and time because,</p><p>1. We are charged for keeping the server up even though the server is not handling any response at that time.<br>2. We have to manage all the maintenance and scaling and be responsible for the uptime.<br>3. We are responsible for the security, the software, and hardware updates.</p><p>This distracts the developers from the main course which is to deliver the best services from the product.</p><p>This where serverless computing comes forward, where developers have to only be concerned about the code and the service provider responsible for provisioning and managing the resources. The code you want to run will be run in stateless containers and can be triggered by events like HTTP requests, database events, and file uploads. This method is also known as Function as a Service(FaaS) because we send code to run in the cloud as functions.</p><p>The following cloud solutions providers are well known for the FaaS offerings.<br>1. AWS — AWS Lambda<br>2. Microsoft Azure — Azure functions<br>3. Google Cloud — Cloud functions</p><p>From here onwards let’s discuss how to build an application with AWS Lambda and react.</p><h4>Building a REST API with AWS Lambda</h4><p>This API will consist of two methods. This will store contacts and retrieve all contacts from AWS Dynamo DB.</p><h4>1. Create a Dynamo DB Table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2ivvxer5c9MMaCqDIyGpg.png" /></figure><p>Go to the AWS dynamo DB console and click on the create table button. Then fill the form and press the create button to create the table.</p><h4>2. Create lambda functions using the AWS Lambda console</h4><p><strong><em>Function to create contact</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YNfoiYeDQsIEDiznGkMI7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6PE-oJSquJbGeKd6cQfuQA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2528d0311eb772d8346f8227bf251a29/href">https://medium.com/media/2528d0311eb772d8346f8227bf251a29/href</a></iframe><p>After writing the code save your work. The uuid module was used here just to create a unique id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zp1MzR2AHDG3DRgdC2UH-g.png" /></figure><p>Create a test event adding necessary parameters to test the function. You have to add the necessary permissions to the function role to write data into the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fX1_X2wu0G4b7y1ig3T7Kw.png" /></figure><p>If you did the tasks correctly, you will pass the test.</p><p>Follow the same steps and create the getContacts lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C0NQdupp_yFp1m6C5H41Gw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad35560b80b4ab475b2636c0e22985f5/href">https://medium.com/media/ad35560b80b4ab475b2636c0e22985f5/href</a></iframe><p>Let’s create the API now.</p><h4>3. Setup the API Gateway</h4><p>Go to the AWS API Gateway console and build a REST API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZC3IsqEhkmLpamMLquGNw.png" /></figure><p>Create a resource in the API. Inside the resource create GET and POST methods for getContacts function and createContact function respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tnqEauXHLN9V_JhaRcPdNA.png" /></figure><p>Then deploy the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WP1c4desyzwr1dKOZGiamw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QXo-YlKhhpo4tfGOmn9F6g.png" /></figure><h4>4. Create a react app to work with the API</h4><p>I made the react app with create-react-app and to access the API, I used the Axios library.</p><p>I will show only the requests here and you can download the code from my <a href="https://github.com/nadunys/ReactLambdaTutorial">Github repository.</a></p><h4><em>Request to get all the contacts</em>.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*x5JpLZAsleraYgXcFD3Zow.png" /></figure><h4>Request to create a contact</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*P7AIPN7bG8m4EM0fSwk-mQ.png" /></figure><p>If you get any error regarding CORS, enable CORS in the API Gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zwJluCFzypkQRj6-nTlqlw.png" /></figure><p>And this is the end of the tutorial. Hope it is informative 😁.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d08ae7bf05ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-ai-team/how-to-create-a-serverless-api-and-use-it-with-react-app-d08ae7bf05ae">How  to  Create  a  Serverless  API  and  use  it  with  React  app</a> was originally published in <a href="https://medium.com/the-ai-team">the-ai.team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>