<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: victory</title>
    <description>The latest articles on DEV Community by victory (@vickywane).</description>
    <link>https://dev.to/vickywane</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F106922%2Fb46e52ab-ecc7-4036-8b30-9a3cab11bb6f.jpg</url>
      <title>DEV Community: victory</title>
      <link>https://dev.to/vickywane</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vickywane"/>
    <language>en</language>
    <item>
      <title>Building An Application Using NuxtJS, Netlify-Functions and RedisJSON</title>
      <dc:creator>victory</dc:creator>
      <pubDate>Tue, 28 Jun 2022 12:24:02 +0000</pubDate>
      <link>https://dev.to/vickywane/building-an-application-using-nuxtjs-netlify-functions-and-redisjson-11hg</link>
      <guid>https://dev.to/vickywane/building-an-application-using-nuxtjs-netlify-functions-and-redisjson-11hg</guid>
      <description>&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;Since the year 2020 when the JAMStack architecture became mainstream and widely used by giant tech companies, the amount of frontend developers building applications with the JAMStack architecture has skyrocketed. &lt;/p&gt;

&lt;p&gt;Following this widespread adoption, this article has put together a tutorial that will guide you through the process of building a JAMStack application for documenting traveling experiences. By using the Redis enterprise cloud, a few clicks can set up a &lt;a href="https://redis.io/docs/stack/json/" rel="noopener noreferrer"&gt;RedisJSON&lt;/a&gt; database with &lt;a href="https://redis.io/docs/stack/search/" rel="noopener noreferrer"&gt;RediSearch&lt;/a&gt; support. &lt;/p&gt;

&lt;h1&gt;
  
  
  What do you need?
&lt;/h1&gt;

&lt;p&gt;This tutorial contains several hands-on steps that will guide you through the process of building the JAMstack application. To follow along, it is assumed that you have the following;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Redis enterprise cloud account.&lt;/li&gt;
&lt;li&gt;Node.js installed on your computer. &lt;/li&gt;
&lt;li&gt;Familiarity with JavaScript and the Vue or NuxtJS frontend frameworks.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Table Of Contents
&lt;/h1&gt;

&lt;p&gt;To make the tutorial easy to follow, it has been broken down into small sections. Feel free to follow through in the order they appear below, or skip to whatever section interests you the most!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating your Redis resources&lt;/li&gt;
&lt;li&gt;Building the Netlify functions&lt;/li&gt;
&lt;li&gt;Building the NuxtJS Application Frontend &lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Creating Your Redis Resources
&lt;/h1&gt;

&lt;p&gt;The quickest way to use Redis is through the Redis Enterprise Cloud as it provides the Redis Stack which comprises RedisJSON and RediSearch. Alternatively, you can set up your own Redis instance using Docker. &lt;/p&gt;

&lt;p&gt;The next section will guide you through the steps of using the Redis Cloud to provision a free Redis instance with a database. &lt;/p&gt;

&lt;h2&gt;
  
  
  Creating A Redis Database
&lt;/h2&gt;

&lt;p&gt;Using your web browser, navigate to the Redis Cloud console. With a free subscription, you are allowed to create one free database.  &lt;/p&gt;

&lt;p&gt;Click the Let’s start free button to proceed with creating a database. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654090465787_Screen%2BShot%2B2022-06-01%2Bat%2B2.30.59%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654090465787_Screen%2BShot%2B2022-06-01%2Bat%2B2.30.59%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Within seconds of clicking the button, a RedisJSON database will be created on AWS within the us-east-1 region. &lt;/p&gt;

&lt;p&gt;Click the provisioned database to navigate to the database details page and copy its connection credentials.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654091249000_Screen%2BShot%2B2022-06-01%2Bat%2B2.44.00%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654091249000_Screen%2BShot%2B2022-06-01%2Bat%2B2.44.00%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Within the &lt;strong&gt;General section&lt;/strong&gt; at the Configuration tab on the next page, note down the Public endpoint value in a secure notepad. The public endpoint will be used to access the database from the JAMStack application.    &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654091811944_Screen%2BShot%2B2022-06-01%2Bat%2B2.55.45%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654091811944_Screen%2BShot%2B2022-06-01%2Bat%2B2.55.45%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scroll down to the Security section to view the authentication credentials for your database.&lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;Copy&lt;/strong&gt; button to copy the  Default user password value to the clipboard. These values will be used to authenticate connections from your JAMstack application to the database. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654092268680_Screen%2BShot%2B2022-06-01%2Bat%2B2.58.45%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654092268680_Screen%2BShot%2B2022-06-01%2Bat%2B2.58.45%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the database fully set up, let’s proceed to generate a NuxtJS project that will store data in the Redis database you created.&lt;/p&gt;

&lt;h1&gt;
  
  
  Generating A NuxtJS Project
&lt;/h1&gt;

&lt;p&gt;NuxtJS is one of the optimized frontend frameworks for building Vue.js applications. Search Engine Optimization (SEO) and Server Side Rendering (SSR) are two notable features that NuxtJS offers to developers. &lt;/p&gt;

&lt;p&gt;To begin using NuxtJS, launch the terminal or command prompt on your computer. You will scaffold a NuxtJS project from your terminal.   &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Execute the npx command below to create a NuxtJS application named &lt;code&gt;redis-jamstack&lt;/code&gt; using the interactive installer;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    npx create-nuxt-app redis-jamstack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During the installation process, make sure to select JavaScript as the programming language and TailwindCSS as the styling framework.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1653845070524_Screen%2BShot%2B2022-05-29%2Bat%2B6.24.16%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1653845070524_Screen%2BShot%2B2022-05-29%2Bat%2B6.24.16%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the NuxtJS project has been generated, execute the command below to move into the &lt;code&gt;redis-jamstack&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;redis-jamstack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next section, you will install two dependencies that are needed for building the application.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Installing The Application Dependencies
&lt;/h2&gt;

&lt;p&gt;Execute the npm command below to install the dependencies. &lt;/p&gt;

&lt;p&gt;You will use the dotenv package to securely retrieve your Redis credentials and establish a connection to your database through the &lt;a href="https://github.com/redis/redis-om-node" rel="noopener noreferrer"&gt;redis-om&lt;/a&gt; package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;dotenv redis-om
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Initializing A Netlify Site
&lt;/h2&gt;

&lt;p&gt;Netlify is one of the most used platforms for developing and deploying JAMStack applications due to the numerous features and developer experience it provides. Each application deployed on Netlify is contained within a site. You will also create a site for the redis-jamstack application. &lt;/p&gt;

&lt;p&gt;Ensure the &lt;a href="https://docs.netlify.com/cli/get-started/" rel="noopener noreferrer"&gt;Netlify-CLI&lt;/a&gt; tool is properly installed on your computer by running the  &lt;code&gt;netlify&lt;/code&gt; command. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654101495341_Screen%2BShot%2B2022-06-01%2Bat%2B5.37.15%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654101495341_Screen%2BShot%2B2022-06-01%2Bat%2B5.37.15%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, execute the command below to initialize a local Netlify site within the redis-jamstack project. After development, you can decide to deploy the local site globally to Netlify.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;netlify init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1653888595545_Screen%2BShot%2B2022-05-30%2Bat%2B6.29.33%2BAM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1653888595545_Screen%2BShot%2B2022-05-30%2Bat%2B6.29.33%2BAM.png" alt="netlify-init.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next step is to securely store your Redis credentials as environment variables within the created site. Netlify provides developers with the option of storing environment variables either through the web-based Netlify dashboard or Netlify-CLI. &lt;/p&gt;

&lt;p&gt;Execute the three commands below to store the public endpoint, username, and password credentials for your Redis database on Netlify.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Replace the placeholders below with the public endpoint, username, and password credentials located within the Configuration tab of the database details page on Redis Cloud.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    &lt;span class="c"&gt;# store database username&lt;/span&gt;
    netlify &lt;span class="nb"&gt;env&lt;/span&gt;:set REDIS_USERNAME DATABASE_USER

    &lt;span class="c"&gt;# store database password&lt;/span&gt;
    netlify &lt;span class="nb"&gt;env&lt;/span&gt;:set REDIS_PASSWORD DATABASE_PASSWORD

    &lt;span class="c"&gt;# store database endpoint&lt;/span&gt;
    netlify &lt;span class="nb"&gt;env&lt;/span&gt;:set REDIS_ENDPOINT DATABSE_PUBLIC_ENDPOINT 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654244770664_Screen%2BShot%2B2022-06-03%2Bat%2B9.24.00%2BAM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654244770664_Screen%2BShot%2B2022-06-03%2Bat%2B9.24.00%2BAM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building The Netlify Functions
&lt;/h2&gt;

&lt;p&gt;In the previous section, you used the Netlify-CLI tool to initialize a local Netlify site and stored credentials for your Redis database as environment variables. Within this section, you will focus on using Netlify-functions to build the API layer of the JAMStack application. &lt;/p&gt;

&lt;p&gt;Netlify Functions are event-driven functions written in either JavaScript, TypeScript, or Go. Netlify-functions are deployed together with the site, and each netlify function is executed when an HTTP request is made to the function’s endpoint which comprises the function’s filename and the site URL. &lt;/p&gt;

&lt;p&gt;Within the redis-jamstack application, you will create three Netlify functions for inserting, reading and searching the Redis database for a travel experience. By default, the file for each netlify-function is located within a nested &lt;code&gt;netlify/functions&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Before you proceed further, let’s specify some configurations for the Netlify-CLI which will be used to run the netlify functions locally before they are deployed to Netlify.&lt;/p&gt;

&lt;p&gt;Using your preferred code editor, create a file named &lt;code&gt;netlify.toml&lt;/code&gt; in the redis-jamstack directory and add the content of the code block below. &lt;/p&gt;

&lt;p&gt;The fields within the dev block will configure the Netlify dev server to run on your localhost at port 5050 and also prevent auto-launching the NuxtJS app in your browser. The wildcard (*) within the headers field will cause the Netlify functions all HTTP accept requests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;    &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;./redis-jamstack/netlify.toml&lt;/span&gt;

    &lt;span class="nn"&gt;[dev]&lt;/span&gt;
    &lt;span class="py"&gt;autoLaunch&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="py"&gt;port&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5050&lt;/span&gt;

    &lt;span class="nn"&gt;[[headers]]&lt;/span&gt;
    &lt;span class="py"&gt;for&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"/*"&lt;/span&gt;
    &lt;span class="nn"&gt;[headers.values]&lt;/span&gt;
    &lt;span class="py"&gt;Access-Control-Allow-Origin&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"*"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you need to create the nested &lt;code&gt;netlify/functions&lt;/code&gt; directory that will store the JavaScript files for your Netlify functions. &lt;/p&gt;

&lt;p&gt;Execute the command below to create a nested directory and change the directory into it. &lt;/p&gt;

&lt;p&gt;Note: If you are using the command prompt on a Windows OS, you will need to manually create the nested directory using the File Explorer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    &lt;span class="c"&gt;# create nested directories&lt;/span&gt;
    &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; netlify/functions

    &lt;span class="c"&gt;# move into functions directory &lt;/span&gt;
    &lt;span class="nb"&gt;cd &lt;/span&gt;netlify/functions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating A Redis Client and Entity
&lt;/h2&gt;

&lt;p&gt;The Redis Object Mapping (Redis-om) package provides you with the ability to model the data for your Node.js applications through the use of custom classes. Rather than using low-level Redis commands such as &lt;code&gt;HSET&lt;/code&gt; and &lt;code&gt;HGET&lt;/code&gt;, you get to use more of JavaScript while interacting with Redis.&lt;/p&gt;

&lt;p&gt;For the redis-jamstack application, you will need to define an entity and a schema that defines &lt;code&gt;username&lt;/code&gt;, &lt;code&gt;travelYear&lt;/code&gt;, &lt;code&gt;travelCountry&lt;/code&gt;, &lt;code&gt;travelState&lt;/code&gt;, and &lt;code&gt;travelExperience&lt;/code&gt; fields contained in a travel experience.  &lt;/p&gt;

&lt;p&gt;Create an &lt;code&gt;entities.js&lt;/code&gt; file to store the entity for each travel experience. Add the code below to define the travel experience entity in the &lt;code&gt;entities.js&lt;/code&gt; file you created. &lt;/p&gt;

&lt;p&gt;One thing to note about the schema below is how the &lt;code&gt;username&lt;/code&gt;, &lt;code&gt;travelExperience&lt;/code&gt;, and &lt;code&gt;travelState&lt;/code&gt; fields have a string type while the &lt;code&gt;travelCountry&lt;/code&gt; field has a text type. Although these fields are similar, the text type provides the ability to perform a partial search using RediSearch without matching the entire value, unlike the string type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// ./redis-jamstack/netlify/functions/entities.js&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Entity&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Schema&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redis-om&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TravelExperience&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Entity&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;travelExperienceSchema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Schema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;TravelExperience&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;travelDuration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;travelCountry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;travelDestination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;travelExperience&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;

        &lt;span class="na"&gt;dateCreated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;dateUpdated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;travelExperienceSchema&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before the entity above is used, you need to establish a connection with your Redis database. As Netlify-functions are stateless, the connection to Redis will be created when a request is sent.&lt;/p&gt;

&lt;p&gt;Create another JavaScript file named &lt;code&gt;client.js&lt;/code&gt; to contain the reusable code for establishing a connection with Redis.&lt;/p&gt;

&lt;p&gt;Add the code below to create an asynchronous function that will establish a connection to Redis and return the Redis instance. To reach your database, the function uses a URL that comprises the Redis credentials that were stored using the Netlify-CLI. &lt;/p&gt;

&lt;p&gt;To further test the connection, a &lt;strong&gt;PING&lt;/strong&gt; command will also be executed to test the connection to your Redis database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// ./redis-jamstack/netlify/functions/client.js&lt;/span&gt;
    &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;config&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Client&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redis-om&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;USERNAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REDIS_USERNAME&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PASSWORD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REDIS_PASSWORD&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;REDIS_ENDPOINT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REDIS_ENDPOINT&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;USERNAME&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;PASSWORD&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;REDIS_ENDPOINT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Your REDIS_USERNAME, REDIS_PASSWORD, and REDIS_ENDPOINT credentials are not defined!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;createRedisClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`redis://&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;USERNAME&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PASSWORD&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;@&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;REDIS_ENDPOINT&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;instance&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createRedisClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, you now have a Redis client instance to interact with your database. Let’s proceed further to write the Netlify functions to insert, delete and search data within the database.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Inserting JSON Data Into The Database
&lt;/h2&gt;

&lt;p&gt;Create a JavaScript file named  &lt;code&gt;create-experience.js&lt;/code&gt;. The &lt;code&gt;create-experience.js&lt;/code&gt;  file will will produce a Netlify function accessible at &lt;code&gt;/.netlify/functions/create-experience&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;Add the code below into the &lt;code&gt;create-experience.js&lt;/code&gt; file to build the logic of the netlify function. The function will parse the stringified object of a user’s travel experience and save it directly using the createAndSave method. on a repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// ./redis-jamstack/netlify/functions/create-experience.js&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createRedisClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;travelExperienceSchema&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./entities&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Redis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createRedisClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

      &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;travelDestination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;travelCountry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;travelDuration&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;travelExperience&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;travelRepository&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;travelExperienceSchema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;createExperience&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;travelRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createAndSave&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
          &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;travelDuration&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;travelCountry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;travelDestination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nx"&gt;travelExperience&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;dateCreated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
          &lt;span class="na"&gt;dateUpdated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createExperience&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toJSON&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;entityId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
              &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Entity &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;entityId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; saved.`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="nx"&gt;data&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;An internal server error occurred&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;error&lt;/span&gt;
          &lt;span class="p"&gt;}),&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reading and Deleting JSON Data From The Database
&lt;/h2&gt;

&lt;p&gt;Create a JavaScript file named &lt;code&gt;experiences.js&lt;/code&gt; to create another Netlify function for storing and deleting a user’s travel experience based on the request method. &lt;/p&gt;

&lt;p&gt;Add the content of the code block below to build the logic of the &lt;code&gt;experiences&lt;/code&gt; function. The following steps are performed: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;A conditional statement is used with the request’s HTTP method to determine when to either delete or retrieve all experience objects. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For a &lt;code&gt;DELETE&lt;/code&gt; request, the function retrieves the ID of the experience about to be deleted from the request’s query parameter and uses the &lt;code&gt;remove&lt;/code&gt; method to delete the data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For the other request methods, all travel experiences stored are indexed and a search operation without a target is performed. Searching without a target ensures that all objects within the database are retrieved and are returned using the &lt;code&gt;returnAll&lt;/code&gt; method. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The amount of data being returned from the &lt;code&gt;returnAll&lt;/code&gt; method is paginated through the &lt;code&gt;pageSize&lt;/code&gt; option with a default of 50 or a &lt;code&gt;limit&lt;/code&gt; value passed in the request parameter.   &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For small applications, executing the &lt;code&gt;createIndex&lt;/code&gt; method at each request execution poses no risk as Redis OM will only rebuild the index only when a schema change is detected. However, re-indexing the data for larger applications will take a while and increase the request latency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// ./redis-jamstack/netlify/functions/experiences.js&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createRedisClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;travelExperienceSchema&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./entities&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;queryStringParameters&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;httpMethod&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Redis&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;createRedisClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

       &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;travelRepository&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchRepository&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;travelExperienceSchema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;queryStringParameters&lt;/span&gt;

           &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;httpMethod&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;DELETE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;travelRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;204&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                        &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Entity &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; removed successfully!`&lt;/span&gt;
                    &lt;span class="p"&gt;}),&lt;/span&gt;
                &lt;span class="p"&gt;};&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;travelRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fetch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;travelRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;returnAll&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;pageSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;limit&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
            &lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toJSON&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                    &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;An internal server error occurred&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="nx"&gt;error&lt;/span&gt;
                &lt;span class="p"&gt;}),&lt;/span&gt;
            &lt;span class="p"&gt;};&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Testing The Netlify Functions
&lt;/h2&gt;

&lt;p&gt;With the Netlify functions built, it is recommended that you make HTTP requests to test the functions before proceeding to consume the endpoints from the NuxtJS application. &lt;/p&gt;

&lt;p&gt;Within this section, you will use the cURL CLI tool which is installed by default in most operating systems. Alternatively, you can use a preferred API client tool such as Postman or Insomnia. &lt;/p&gt;

&lt;p&gt;To begin, execute the command below to move back to the redis-jamstack directory and start the Netlify development server. The Netlify dev server will run both the Netlify functions and NuxtJS application locally for you to test before deploying to Netlify.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    &lt;span class="nb"&gt;cd&lt;/span&gt; ../../ 

    netlify dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654244173367_Screen%2BShot%2B2022-06-03%2Bat%2B9.15.16%2BAM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654244173367_Screen%2BShot%2B2022-06-03%2Bat%2B9.15.16%2BAM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Execute the command below to make a POST request to the create-experience function with a JSON object containing fields that describe a travel experience.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://localhost:5050/.netlify/functions/create-experience &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{ "username" : "vickywane", "travelDuration" : "2 years", "travelDestination" : "Nigeria", "travelExperience": "nice place", "travelCountry":"Nigeria" }'&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the right side of the image below, you will see the request sent and the response returned. The outlined Netlify logs at the left show the POST request received and the time is taken to process it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654245499969_Screen%2BShot%2B2022-06-03%2Bat%2B9.35.50%2BAM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654245499969_Screen%2BShot%2B2022-06-03%2Bat%2B9.35.50%2BAM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Execute the command below to make a GET request to the function of the experience to retrieve all objects within the Redis database.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:5050/.netlify/functions/experiences
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looking at the result below, you will observe a data field containing an array with a single object holding your previous request. More objects will be returned if you execute the POST requests in step 1 multiple times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654245720686_Screen%2BShot%2B2022-06-03%2Bat%2B9.39.39%2BAM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654245720686_Screen%2BShot%2B2022-06-03%2Bat%2B9.39.39%2BAM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Execute the command below to make a DELETE request to the experiences function with a JSON object containing fields that describe a travel experience.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:5050/.netlify/functions/experiences
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654256144037_Screen%2BShot%2B2022-06-03%2Bat%2B12.33.10%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654256144037_Screen%2BShot%2B2022-06-03%2Bat%2B12.33.10%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s it! &lt;/p&gt;

&lt;p&gt;You can now assume that the two Netlify functions are working as expected and proceed to consume them while building the frontend part of the NextJS application. &lt;/p&gt;

&lt;h1&gt;
  
  
  Building The Application Frontend
&lt;/h1&gt;

&lt;p&gt;The NuxtJS application will contain two pages; one to display all travel experiences, and the other to create a new travel experience. &lt;/p&gt;

&lt;h2&gt;
  
  
  Creating The Application Components
&lt;/h2&gt;

&lt;p&gt;Using your code editor, create a file named &lt;code&gt;Header.vue&lt;/code&gt; within the &lt;code&gt;src/component&lt;/code&gt; directory. The &lt;code&gt;Header.vue&lt;/code&gt; file will contain the Header displayed across the two pages within the application. &lt;/p&gt;

&lt;p&gt;Add the content of the code block below into the &lt;code&gt;Header.vue&lt;/code&gt; file;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c"&gt;&amp;lt;!--&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;redis&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;jamstack&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;components&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;vue&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;nav&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;w-full h-14 flex items-center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px-4 flex w-full justify-between&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;nuxt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-xl font-semibold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Redis&lt;/span&gt; &lt;span class="nx"&gt;Travel&lt;/span&gt; &lt;span class="nx"&gt;JAMStack&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/nuxt-link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;nuxt&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/create-experience&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mr-4 hover:cursor-pointer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                &lt;span class="o"&gt;&amp;gt;+&lt;/span&gt; &lt;span class="nx"&gt;Add&lt;/span&gt; &lt;span class="nx"&gt;Travel&lt;/span&gt; &lt;span class="nx"&gt;Experience&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/nuxt-link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/nav&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/header&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/template&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Header&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, create another file named &lt;code&gt;ExperienceCard.vue&lt;/code&gt; within the same &lt;code&gt;src/component directory. The Vue component within the&lt;/code&gt;ExperienceCard.vue` file will be used on the default page to travel experiences.   &lt;/p&gt;

&lt;p&gt;Add the code below into &lt;code&gt;ExperienceCard.vue&lt;/code&gt; file to build the component. The code below uses props passed in from the &lt;code&gt;Index.vue&lt;/code&gt; component to display a user’s travel experience. The code also contains a click handler that will make a DELETE request to delete the current experience. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`javascript&lt;br&gt;
    &amp;lt;!-- ./redis-jamstack/components/ExperienceCard.vue --&amp;gt;&lt;br&gt;
    &lt;br&gt;
      &lt;br&gt;
        &lt;br&gt;
          &lt;br&gt;
            Written by&lt;br&gt;
            &lt;br&gt;
              {{ username }}&lt;br&gt;
            &lt;br&gt;
            on a&lt;br&gt;
            &lt;br&gt;
              {{ duration }}&lt;br&gt;
            &lt;br&gt;
            visit to&lt;br&gt;
            &lt;br&gt;
              {{ country }}&lt;br&gt;
            &lt;br&gt;
            at&lt;br&gt;
            &lt;br&gt;
              {{ destination }}&lt;br&gt;
            &lt;br&gt;
          &lt;br&gt;
          
            &lt;a class="mentioned-user" href="https://dev.to/click"&gt;@click&lt;/a&gt;="deleteExperience(itemId)"&lt;br&gt;
            class="&lt;br&gt;
              flex&lt;br&gt;
              justify-center&lt;br&gt;
              hover:text-white&lt;br&gt;
              cursor-pointer&lt;br&gt;
              rounded&lt;br&gt;
              p-1&lt;br&gt;
              hover:bg-gray-100&lt;br&gt;
              h-8&lt;br&gt;
              w-8&lt;br&gt;
              hover:bg-red-800&lt;br&gt;
            "&lt;br&gt;
          &amp;gt;&lt;br&gt;
            
              xmlns="http://www.w3.org/2000/svg"&lt;br&gt;
              class="h-5 w-5"&lt;br&gt;
              viewBox="0 0 20 20"&lt;br&gt;
              fill="currentColor"&lt;br&gt;
            &amp;gt;&lt;br&gt;
              
                fill-rule="evenodd"&lt;br&gt;
                d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"&lt;br&gt;
                clip-rule="evenodd"&lt;br&gt;
              /&amp;gt;&lt;br&gt;
            &lt;br&gt;
          &lt;br&gt;
        &lt;br&gt;
        &lt;/p&gt;

&lt;br&gt;
        &lt;br&gt;
          &lt;p&gt;{{ description }}&lt;/p&gt;
&lt;br&gt;
        &lt;br&gt;
        
&lt;br&gt;
        &lt;br&gt;
          &lt;p&gt;&lt;br&gt;
            Created on&lt;br&gt;
            {{ new Date(dateCreated).toDateString() }}&lt;br&gt;
          &lt;/p&gt;
&lt;br&gt;
        &lt;br&gt;
      &lt;br&gt;
    &lt;br&gt;
    
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default {
  name: "ExperienceCard",
  data: () =&amp;gt; ({
    isEmpty: false,
  }),
  props: {
    itemId: "",
    username: "",
    dateCreated: "",
    description: "",
    country: "",
    destination: "",
    duration: "",
  },
  methods: {
    deleteExperience: async function (id) {
      try {
        if (!id) {
          console.error("EntityID for travel experience is missing!!");
          return;
        }

        const { status } = await fetch(
          `/.netlify/functions/experiences?id=${id}`,
          {  method: "DELETE" }
        );

        if (status === 204) {
          this.isEmpty = true;
          console.log("IS EMPTY", this.isEmpty);
        }
      } catch (error) {
        console.log("Error deleting item:", error);
      }
    },
  },
};
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With the Header and ExperienceCard components built out, let’s move on to use these components within the two pages in the NuxtJS application.&lt;/p&gt;

&lt;p&gt;Creating The Application Pages&lt;/p&gt;

&lt;p&gt;Next, replace the code within the index.vue file with the code below to fetch all experiences immediately after the page is loaded, and display them using the ExperienceCard component.   &lt;/p&gt;

&lt;p&gt;The Index component also handles the loading state of the application and scenarios where the are no existing experiences.  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`javascript&lt;br&gt;
    &amp;lt;!-- ./redis-jamstack/pages/Index.vue --&amp;gt;&lt;br&gt;
    &lt;br&gt;
      &lt;br&gt;
        &lt;br&gt;
        &lt;/p&gt;

&lt;br&gt;
        
          class="&lt;br&gt;
            mt-1&lt;br&gt;
            h-96&lt;br&gt;
            bg-gradient-to-tr&lt;br&gt;
            from-green-300&lt;br&gt;
            via-blue-500&lt;br&gt;
            to-purple-600&lt;br&gt;
            flex&lt;br&gt;
            justify-center&lt;br&gt;
            items-center&lt;br&gt;
          "&lt;br&gt;
        &amp;gt;&lt;br&gt;
          &lt;h1&gt;
&lt;br&gt;
            Live, Love, and Document &lt;br&gt;&lt;br&gt;
            Your Travel Experiences!&lt;br&gt;
          &lt;/h1&gt;
&lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
          
            class="h-64 flex justify-center items-center"&lt;br&gt;
            v-if="isLoadingExperiences"&lt;br&gt;
          &amp;gt;&lt;br&gt;
            &lt;p&gt;Fetching travel experiences...&lt;/p&gt;
&lt;br&gt;
          &lt;br&gt;
          &lt;br&gt;
            &lt;br&gt;
              
                class="&lt;br&gt;
                  rounded-xl&lt;br&gt;
                  shadow-lg&lt;br&gt;
                  h-20&lt;br&gt;
                  w-4/5&lt;br&gt;
                  bg-white&lt;br&gt;
                  flex&lt;br&gt;
                  px-8&lt;br&gt;
                  justify-between&lt;br&gt;
                  items-center&lt;br&gt;
                "&lt;br&gt;
              &amp;gt;&lt;br&gt;
                &lt;br&gt;
                  &lt;p&gt;&lt;br&gt;
                    {{ experiences.length }} Experiences Available&lt;br&gt;
                  &lt;/p&gt;
&lt;br&gt;
                &lt;br&gt;
                &lt;br&gt;
                  &lt;br&gt;
                    
                      class="&lt;br&gt;
                        bg-blue-500&lt;br&gt;
                        hover:bg-blue-700&lt;br&gt;
                        text-white&lt;br&gt;
                        font-bold&lt;br&gt;
                        py-2&lt;br&gt;
                        px-4&lt;br&gt;
                        rounded&lt;br&gt;
                      "&lt;br&gt;
                    &amp;gt;&lt;br&gt;
                      Create Experience&lt;br&gt;
                    &lt;br&gt;
                  &lt;br&gt;
                &lt;br&gt;
              &lt;br&gt;
            &lt;br&gt;
            &lt;br&gt;&lt;br&gt;
            &lt;br&gt;
              
                class="h-96 flex justify-center items-center"&lt;br&gt;
                v-if="experiences.length &amp;lt;= 0"&lt;br&gt;
              &amp;gt;&lt;br&gt;
                &lt;br&gt;
                  &lt;p&gt;&lt;br&gt;
                    Travel experiences have not yet been created.&lt;br&gt;
                  &lt;/p&gt;
&lt;br&gt;
                  &lt;p&gt;Be the first to tell a travel story!&lt;/p&gt;
&lt;br&gt;
                  &lt;br&gt;
                    &lt;br&gt;
                      Tell Our First Travel Experience -&amp;gt;&lt;br&gt;
                    &lt;br&gt;
                  &lt;br&gt;
                &lt;br&gt;
              &lt;br&gt;
              &lt;ul&gt;

                &lt;li&gt;

                  
                    :itemId="item.entityId"
                    :duration="item.travelDuration"
                    :username="item.username"
                    :dateCreated="item.dateCreated"
                    :country="item.travelCountry"
                    :description="item.travelExperience"
                    :destination="item.travelDestination"
                  /&amp;gt;
                &lt;/li&gt;

              &lt;/ul&gt;
&lt;br&gt;
            &lt;br&gt;
          &lt;br&gt;
        &lt;br&gt;
      &lt;br&gt;
    
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
import Header from "../components/Header.vue";
import ExperienceCard from "../components/ExperienceCard.vue";

export default {
  name: "IndexPage",
  mounted() {
    try {
      this.isLoadingExperiences = true;
      (async () =&amp;gt; {
        const req = await fetch("/.netlify/functions/experiences");
        const { data } = await req.json();
        this.experiences = data;
      })();
    } catch (e) {
      console.log(e);
    } finally {
      this.isLoadingExperiences = false;
    }
  },
  components: {
    Header,
    ExperienceCard,
  },
  data: () =&amp;gt; ({
    isLoadingExperiences: false,
    experiences: [],
  }),
};
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;   &lt;/p&gt;

&lt;p&gt;Using your web browser, navigate to the default page of the redis-jamstack application at &lt;code&gt;http://localhost:5050&lt;/code&gt;. The default page will be displayed without an experience as your redis-database is pretty empty.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654268368548_Screen%2BShot%2B2022-06-03%2Bat%2B3.58.01%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654268368548_Screen%2BShot%2B2022-06-03%2Bat%2B3.58.01%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, you will create a page containing a form that users will use to input the details of a travel experience. &lt;/p&gt;

&lt;p&gt;Within the pages directory, create a file named &lt;code&gt;create-experience.vue&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Add the code below to the &lt;code&gt;create-experience.vue&lt;/code&gt; file to create a form with several input fields for collecting the username, country, experience, and destination details of a user’s trip. &lt;/p&gt;

&lt;p&gt;At the click of the &lt;strong&gt;Save Your Experience&lt;/strong&gt; button, a &lt;code&gt;POST&lt;/code&gt; request will be executed to submit the values within the form.  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`javascript&lt;br&gt;
    &amp;lt;!-- ./redis-jamstack/pages/create-experience.vue --&amp;gt;&lt;br&gt;
    &lt;br&gt;
      &lt;br&gt;
        
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;div
      style="height: 93vh"
      class="h-full bg-gray-100 flex justify-center items-center w-full"
    &amp;gt;
      &amp;lt;div class="bg-white rounded-lg w-7/12 shadow-lg p-4"&amp;gt;
        &amp;lt;div class="mb-8"&amp;gt;
          &amp;lt;h1 class="text-center text-xl mb-2"&amp;gt;
            Document your travel experience
          &amp;lt;/h1&amp;gt;
          &amp;lt;hr /&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;form class="w-full"&amp;gt;
          &amp;lt;div class="flex flex-wrap -mx-3 mb-6"&amp;gt;
            &amp;lt;div class="w-full px-3"&amp;gt;
              &amp;lt;label
                class="
                  block
                  uppercase
                  tracking-wide
                  text-gray-700 text-xs
                  font-bold
                  mb-2
                "
                for="username"
              &amp;gt;
                What is your name?
              &amp;lt;/label&amp;gt;
              &amp;lt;input
                v-model="username"
                class="
                  appearance-none
                  block
                  w-full
                  bg-gray-200
                  text-gray-700
                  border border-gray-200
                  rounded
                  py-3
                  px-4
                  mb-3
                  leading-tight
                  focus:outline-none focus:bg-white focus:border-gray-500
                "
                id="username"
                type="text"
                placeholder="John Doe"
              /&amp;gt;
              &amp;lt;p class="text-gray-600 text-xs italic"&amp;gt;
                (Use "anonymous" to stay unkown)
              &amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;p
            class="
              block
              uppercase
              tracking-wide
              text-gray-700 text-xs
              font-bold
              mb-4
            "
          &amp;gt;
            Where Did You Travel To?
          &amp;lt;/p&amp;gt;
          &amp;lt;div class="flex flex-wrap -mx-2 mb-2"&amp;gt;
            &amp;lt;div class="w-full md:w-1/3 px-3 mb-6 md:mb-0"&amp;gt;
              &amp;lt;label
                class="
                  block
                  uppercase
                  tracking-wide
                  text-gray-700 text-xs
                  font-semibold
                  mb-2
                "
                for="country"
              &amp;gt;
                Country
              &amp;lt;/label&amp;gt;
              &amp;lt;input
                v-model="travelCountry"
                class="
                  appearance-none
                  block
                  w-full
                  bg-gray-200
                  text-gray-700
                  border border-gray-200
                  rounded
                  py-3
                  px-4
                  leading-tight
                  focus:outline-none focus:bg-white focus:border-gray-500
                "
                id="country"
                type="text"
                placeholder="Country Visited."
              /&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="w-full md:w-1/3 px-3 mb-6 md:mb-0"&amp;gt;
              &amp;lt;label
                class="
                  block
                  uppercase
                  tracking-wide
                  text-gray-700 text-xs
                  font-semibold
                  mb-2
                "
                for="duration"
              &amp;gt;
                Trip duration
              &amp;lt;/label&amp;gt;
              &amp;lt;input
                v-model="travelDuration"
                class="
                  appearance-none
                  block
                  w-full
                  bg-gray-200
                  text-gray-700
                  border border-gray-200
                  rounded
                  py-3
                  px-4
                  leading-tight
                  focus:outline-none focus:bg-white focus:border-gray-500
                "
                id="duration"
                type="text"
                placeholder="Time spent"
              /&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="w-full md:w-1/3 px-3 mb-6 md:mb-0"&amp;gt;
              &amp;lt;label
                class="
                  block
                  uppercase
                  tracking-wide
                  text-gray-700 text-xs
                  font-semibold
                  mb-2
                "
                for="destination"
              &amp;gt;
                Destination
              &amp;lt;/label&amp;gt;
              &amp;lt;input
                class="
                  appearance-none
                  block
                  w-full
                  bg-gray-200
                  text-gray-700
                  border border-gray-200
                  rounded
                  py-3
                  px-4
                  leading-tight
                  focus:outline-none focus:bg-white focus:border-gray-500
                "
                v-model="travelDestination"
                id="destination"
                type="text"
                placeholder="Place visited. E.g Rio De Janeiro"
              /&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div class="flex flex-wrap mx-1 mb-6 mt-6"&amp;gt;
              &amp;lt;div class="w-full px-3"&amp;gt;
                &amp;lt;label
                  class="
                    block
                    uppercase
                    tracking-wide
                    text-gray-700 text-xs
                    font-bold
                    mb-4
                  "
                  for="experience"
                &amp;gt;
                  How was your travel experience?
                &amp;lt;/label&amp;gt;
                &amp;lt;textarea
                  v-model="travelExperience"
                  style="height: 20vh; width: 50rem ; flex: 1; box-sizing: border-box"
                  class="
                    appearance-none
                    w-full
                    bg-gray-200
                    text-gray-700
                    border border-gray-200
                    rounded
                    py-3
                    px-4
                    mb-3
                    focus:outline-none focus:bg-white focus:border-gray-500
                  "
                  id="experience"
                  type="text"
                  placeholder="How did traveling make you feel?"
                /&amp;gt;
                &amp;lt;p class="text-gray-600 text-xs italic"&amp;gt;Tell It All!&amp;lt;/p&amp;gt;
              &amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;hr class="mt-8" /&amp;gt;
          &amp;lt;div class="flex justify-between mt-4"&amp;gt;
            &amp;lt;button
              class="
                bg-gray-300
                hover:bg-gray-400
                text-gray-800
                font-bold
                py-2
                px-4
                rounded
                inline-flex
                mr-4
                items-center
              "
            &amp;gt;
              &amp;lt;nuxt-link to="/"&amp;gt; Go Back &amp;lt;/nuxt-link&amp;gt;
            &amp;lt;/button&amp;gt;
            &amp;lt;button
              :disabled="isSubmitting"
              @click="submitExperience"
              type="submit"
              class="
                bg-blue-500
                hover:bg-blue-700
                text-white
                font-bold
                py-2
                px-4
                rounded
              "
            &amp;gt;
              {{ !isSubmitting ? "Save" : "Saving" }} Your Experience
            &amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/form&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import Header from "../components/Header.vue";

export default {
  name: "create-experience",
  components: { Header },
  data: () =&amp;gt; ({
    username: "",
    travelCountry: "",
    travelDestination: "",
    travelDuration: "",
    travelExperience: "",
    isSubmitting: false
  }),
  methods: {
    submitExperience: async function (event) {
      event.preventDefault();
      const postReq = await fetch(`/.netlify/functions/create-experience`, {
        method: "POST",
        body: JSON.stringify({
          username: this.username,
          travelCountry: this.travelCountry,
          travelDestination: this.travelDestination,
          travelExperience: this.travelExperience,
          travelDuration: this.travelDuration
        }),
      });
      if (postReq.status === 200) {
        await postReq.json();
        this.$router.push({
          path: "/"
        })
      }
    },
  },
};
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;From the default page, click the Create Experience button to navigate to the create-experience page at &lt;code&gt;http://localhost:5050/create-experience&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;On the create-experience page, type in the details of your last trip or a trip at the &lt;strong&gt;name&lt;/strong&gt;, &lt;strong&gt;country&lt;/strong&gt;, &lt;strong&gt;duration&lt;/strong&gt;, and &lt;strong&gt;destination&lt;/strong&gt; fields.&lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;Save Your Experience&lt;/strong&gt; button to save the travel details you typed. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654369547869_Screen%2BShot%2B2022-06-04%2Bat%2B1.09.25%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654369547869_Screen%2BShot%2B2022-06-04%2Bat%2B1.09.25%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a successful save, the application will redirect you to the default page to view your travel experience. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654370595972_Screen%2BShot%2B2022-06-04%2Bat%2B8.22.38%2BPM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_CF4C845A6A3F6F172F7C762A2AC80B60E1F7081CFDED5CD172CC5A81BF46D013_1654370595972_Screen%2BShot%2B2022-06-04%2Bat%2B8.22.38%2BPM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s it!&lt;/p&gt;

&lt;p&gt;Your minimal JAMstack application powered by a RedisJSON database provisioned within the Redis cloud is now complete. &lt;/p&gt;


</description>
    </item>
    <item>
      <title>Build modern ecommerce with Svelte and Medusa</title>
      <dc:creator>victory</dc:creator>
      <pubDate>Mon, 13 Dec 2021 09:24:27 +0000</pubDate>
      <link>https://dev.to/vickywane/building-a-svelte-storefront-using-medusa-commerce-5eek</link>
      <guid>https://dev.to/vickywane/building-a-svelte-storefront-using-medusa-commerce-5eek</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.medusajs.com"&gt;Medusa&lt;/a&gt; is an open-source headless commerce engine built for developers. The engine gives you the primitives to create amazing digital commerce experiences. Customization and flexibility is of highest priority and is enabled through an open-source foundation and unique plugin architecture. Additionally, Medusa solves common pain points of most monolithic ecommerce solutions such as multi-regional support, flexibility in the tech stack, automated exchange handling and more.&lt;/p&gt;

&lt;p&gt;The headless element of Medusa likewise gives you the flexibility to build or add any frontend application or channel of your preference on top of Medusa. In this tutorial, we will set up a Medusa powered store with a Svelte frontend using our newly built Svelte starter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; is a frontend framework similar to &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt; and &lt;a href="https://vuejs.org/"&gt;VueJS&lt;/a&gt; which has gained increasing popularity in recent years. Main reason for the traction has been Svelte ability to improve frontend performance by compiling the web components (HTML, CSS and Javascript) into small standalone Javascript modules that are run at build time.&lt;/p&gt;

&lt;p&gt;In this tutorial the focus will be on the Svelte starter. If you are interested in using Medusa with other frameworks instead, you can check out our &lt;a href="https://github.com/medusajs/nextjs-starter-medusa"&gt;Next.js&lt;/a&gt; and &lt;a href="https://github.com/medusajs/gatsby-starter-medusa-simple"&gt;Gatsby&lt;/a&gt; starters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;This tutorial requires you to have a Medusa store engine running locally on your machine. Get started quickly using our CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install our CLI&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @medusajs/medusa-cli

&lt;span class="c"&gt;# Create a new project&lt;/span&gt;
medusa new my-medusa-store

&lt;span class="c"&gt;# Navigate to your project and start your server locally&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;my-medusa-store
medusa develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure that Medusa is running on port &lt;code&gt;9000&lt;/code&gt; to avoid potential CORS issues when connecting the your Svelte application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation and usage
&lt;/h2&gt;

&lt;p&gt;To get started with the Svelte starter, launch a new terminal tab on your machine and execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx degit vickywane/svelte-starter-medusa my-storefront
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The commands will scaffold a Svelte application for you called my-storefront.&lt;/p&gt;

&lt;p&gt;Next, navigate to your Svelte project, install the dependencies and launch your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Navigate to your project&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;my-storefront

&lt;span class="c"&gt;# Install all dependencies&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Start up your Svelte applcation&lt;/span&gt;
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure that your Svelte application is running on port 8000. Again, to prevent CORS issues from occurring.&lt;/p&gt;

&lt;p&gt;Go to &lt;code&gt;http://localhost:8000&lt;/code&gt; and view your newly create storefront. To play with the starter, you are required to add some initial data to your Medusa store. If you haven't done this already, navigate to your Medusa project and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Will seed your database with some predefined dummy data&lt;/span&gt;
npm run seed

&lt;span class="c"&gt;# start the server with new data&lt;/span&gt;
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, if you refresh your Svelte application, you should see a product displayed on the front page. The out-of-the-box functionality in the starter allows you to add the product to your cart and complete a checkout flow.&lt;/p&gt;

&lt;p&gt;‍&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;As a result of following this tutorial, you are provided with the foundation to built an amazing digital commerce experience using the Svelte framework. Browse through the official Medusa documentation to learn more about extending your store engine with custom functionality and plugins.&lt;/p&gt;

&lt;p&gt;If you stumble upon issues, or have questions, feel free to join our Discord and get in touch with the Medusa engineering team.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
