<?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: mirwaissh</title>
    <description>The latest articles on DEV Community by mirwaissh (@mirwaissh).</description>
    <link>https://dev.to/mirwaissh</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%2F718502%2Fe94335cb-b523-4213-9095-47ae3945a810.jpeg</url>
      <title>DEV Community: mirwaissh</title>
      <link>https://dev.to/mirwaissh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mirwaissh"/>
    <language>en</language>
    <item>
      <title>Leveraging Qlik Users API - Building a PWA Dashboard with Nextjs, Typescript &amp; Chakra-UI</title>
      <dc:creator>mirwaissh</dc:creator>
      <pubDate>Mon, 04 Oct 2021 23:21:07 +0000</pubDate>
      <link>https://dev.to/mirwaissh/leveraging-qlik-users-api-building-a-pwa-dashboard-with-nextjs-typescript-chakra-ui-3f9g</link>
      <guid>https://dev.to/mirwaissh/leveraging-qlik-users-api-building-a-pwa-dashboard-with-nextjs-typescript-chakra-ui-3f9g</guid>
      <description>&lt;h1&gt;
  
  
  What is Qlik APIs
&lt;/h1&gt;

&lt;p&gt;Qlik APIs for SaaS editions are public APIs that enables to build, extend and deploy powerful and engaging analytics into your applications, you can also build custom data-driven apps that's blazing fast and deliver high quality software for automations, aviation and education industries.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rwf24hax0x412w1jeiz.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rwf24hax0x412w1jeiz.png" alt="qlik APIs plaform"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The platform delivers realtime data which is scaleable and maintainable in various form such us object store, data warehouse, streaming services and relational &amp;amp; non-relational repositories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can read more about the API platform here: &lt;a href="https://qlik.dev/apis" rel="noopener noreferrer"&gt;https://qlik.dev/apis&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;With this Article we are going to focus and start using the Users API and build a powerful and scaleable dashboard platform. The platform will be build as Progressive Web App(PWA) that is installable in any device that supports modern browsers such us Chrome web browser. The framework that we will be building the platform is Nextjs which is a blazing fast framework built on top of Reactjs. For the UI components we will be using Chakra-UI component library which is light weight, super easy design system implementation library.&lt;/p&gt;

&lt;p&gt;To understand and read more about PWA, Nextjs and Chakra-UI refer to the following links:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PWA&lt;/strong&gt;&lt;br&gt;
A progressive web application is a type of application software delivered through the web, built using common web technologies including HTML, CSS and JavaScript. It is intended to work on any platform that uses a standards-compliant browser, including both desktop and mobile devices.&lt;br&gt;
Read more here: &lt;br&gt;
&lt;a href="https://web.dev/what-are-pwas/" rel="noopener noreferrer"&gt;https://web.dev/what-are-pwas/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nextjs&lt;/strong&gt;&lt;br&gt;
Next.js is an open-source development framework built on top of Node.js enabling React based web applications functionalities such as server-side rendering and generating static websites.&lt;br&gt;
Read more about here: &lt;br&gt;
&lt;a href="https://nextjs.org/learn/basics/create-nextjs-app?utm_source=next-site&amp;amp;utm_medium=homepage-cta&amp;amp;utm_campaign=next-website" rel="noopener noreferrer"&gt;https://nextjs.org/learn/basics/create-nextjs-app?utm_source=next-site&amp;amp;utm_medium=homepage-cta&amp;amp;utm_campaign=next-website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chakra-UI&lt;/strong&gt;&lt;br&gt;
Chakra UI is a simple, modular and accessible component library that gives you the building blocks you need to build your React applications.&lt;br&gt;
I find Chakra-UI the best #React component framework &lt;a href="https://chakra-ui.com" rel="noopener noreferrer"&gt;https://chakra-ui.com&lt;/a&gt; Provides just enough to get started, implements sensible defaults, but is also very extensible and customisable because it uses styled system and emotion css.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chakra-ui.com/docs/getting-started" rel="noopener noreferrer"&gt;https://chakra-ui.com/docs/getting-started&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alright, enough of introduction let's focus on building the platform&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the app that we will be building:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9smem785c9s9q2nc8twp.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9smem785c9s9q2nc8twp.png" alt="dashboard app screenshot"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;In order to save you all some work, I have already setup a starter template, thats configured to the following configurations, remember again don't be confused and I will explain each packages that is used:&lt;/p&gt;

&lt;p&gt;Here is the project starter template on github, download it and save it in your computer direcotry:&lt;br&gt;
&lt;a href="https://github.com/mirwaissh/starter-template" rel="noopener noreferrer"&gt;https://github.com/mirwaissh/starter-template&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The template is A TypeScript starter for Next.js that includes all you need to build amazing projects 🔥&lt;/p&gt;

&lt;p&gt;📏 ESLint — Pluggable JavaScript linter&lt;br&gt;
💖 Prettier - Opinionated Code Formatter&lt;br&gt;
🐶 Husky — Use git hooks with ease&lt;br&gt;
📄 Commitizen - Conventional commit messages CLI&lt;br&gt;
🚓 Commitlint - Lint commit messages&lt;br&gt;
🖌 Renovate - Dependency update tool&lt;br&gt;
🚫 lint-staged - Run linters against staged git files&lt;br&gt;
👷 PR Workflow - Run Type Check &amp;amp; Linters on pull requests&lt;br&gt;
🗂 Absolute import - Import folders and files using the @ prefix&lt;/p&gt;

&lt;p&gt;Remember the goal with these configuration and packages are so we can have a solid and scaleable platform, all they are is just configuration and you can start looking at npm package managers for more information for each package. I will explain these packages later in the article, for now bear with me and we have not written any code yet. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To start the application:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you have downloaded the template, go on and run the following command to install the packages that is required in &lt;em&gt;package.json&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a successful packages installation run the following command to start the platform on dev mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the server now runs on:&lt;br&gt;
&lt;strong&gt;&lt;a href="http://localhost:3000/" rel="noopener noreferrer"&gt;http://localhost:3000/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Building the UI Components
&lt;/h3&gt;

&lt;p&gt;As mentioned before we will be using Chakra-UI for building our component, so go on and run the following command to install the packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now that we have the packages installed, let's go and do some clean up and create our components directory structure&lt;/p&gt;

&lt;p&gt;header over to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/pages/index.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and get rid of the entire div from top to bottom, so the Home page will return nothing at this moment. To clearify, it should look like following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from 'next/head';
import Image from 'next/image';

import styles from '@/styles/Home.module.css';

export default function Home() {
  return (

  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;create a new directory called components&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/componets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;inside the components directory, create a new component called Header.tsx
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/componets/Header.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Box, Text } from '@chakra-ui/layout';

const Header: React.FC&amp;lt;any&amp;gt; = (): React.ReactElement =&amp;gt; {
  return (
    &amp;lt;Box
      padding="2rem"
      color="blue"
      fontSize="1.3rem"
      fontWeight="bold"
      backgroundColor="yellow"
    &amp;gt;
      &amp;lt;Text textAlign="center"&amp;gt;Dashboard&amp;lt;/Text&amp;gt;
    &amp;lt;/Box&amp;gt;
  );
};

export default Header;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This a simple React component that returns a text with "Dashboard". So remember in plain html, we had div and p tag, however in chakra-ui we have box and Text, that the only difference. One really cool feature about chakra is you can type css in js, save you time and effort.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We are good for now.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;header over to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/pages/index.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and update it with following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from 'next/head';
import Header from '@/Components/Header';
import { Box } from '@chakra-ui/layout';
import styles from '@/styles/Home.module.css';

export default function Home() {
  return (
    &amp;lt;Box&amp;gt;
      &amp;lt;Head&amp;gt;
        &amp;lt;title&amp;gt;Qlik cloud users&amp;lt;/title&amp;gt;
      &amp;lt;/Head&amp;gt;
      &amp;lt;Header&amp;gt;&amp;lt;/Header&amp;gt;
    &amp;lt;/Box&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are adding the Header Component to render in the Index, and also adding a title to the web page, inside the Head of the page. This is how you update webpage title in Nextjs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cool&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now Lets go and create Our UserList module inside the component directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/pages/UserList.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and update it with following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Box, Text } from '@chakra-ui/layout';
import {
  ListItem,
  UnorderedList,
  Image,
} from '@chakra-ui/react';

interface UserProps {
  users: Array&amp;lt;any&amp;gt;;
}

const UserList: React.FC&amp;lt;any&amp;gt; = ({ users }: UserProps) =&amp;gt; {
  return (
    &amp;lt;Box&amp;gt;
      &amp;lt;Box&amp;gt;
        &amp;lt;Text marginBottom="2rem" fontSize="0.9rem" textAlign="center"&amp;gt;
          Active Users
        &amp;lt;/Text&amp;gt;
      &amp;lt;/Box&amp;gt;
      &amp;lt;UnorderedList
        padding="0"
        margin="0"
        listStyleType="none"
        display="flex"
        flexDirection="column"
        alignItems="center"
      &amp;gt;
        {users.map((user) =&amp;gt; (
          &amp;lt;ListItem&amp;gt;
            &amp;lt;Box width="100px" height="100px"&amp;gt;
              &amp;lt;Image
                width="100%"
                height="100%"
                borderRadius="10px"
                src={user.imageSrc}
              &amp;gt;&amp;lt;/Image&amp;gt;
            &amp;lt;/Box&amp;gt;
            &amp;lt;Box&amp;gt;
              &amp;lt;Text textAlign="center" textTransform="capitalize"&amp;gt;
                {user.name}
              &amp;lt;/Text&amp;gt;
            &amp;lt;/Box&amp;gt;
          &amp;lt;/ListItem&amp;gt;
        ))}
      &amp;lt;/UnorderedList&amp;gt;
    &amp;lt;/Box&amp;gt;
  );
};

export default UserList;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This components accepts and Array of users and render a list item for each user. Remember this users array comes as props, we will be passing in the next step.&lt;/p&gt;

&lt;p&gt;great... so far so good.&lt;/p&gt;

&lt;p&gt;Now again, Now Lets go and create Our HomeComponent module inside the component directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/pages/HomeComponent.tsx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState, useEffect, useCallback } from 'react';
import UserList from './UserList';
import { Box } from '@chakra-ui/layout';


const HomeComponent: React.FC&amp;lt;any&amp;gt; = (): React.ReactElement =&amp;gt; {
  const [users, setUsers] = useState&amp;lt;object[]&amp;gt;([]);
  const [loading, setLoading] = useState&amp;lt;null | boolean&amp;gt;(null);
  const [requestError, setRequestError] = useState&amp;lt;string&amp;gt;('');

  return &amp;lt;Box&amp;gt;{!loading &amp;amp;&amp;amp; &amp;lt;UserList users={users}&amp;gt;&amp;lt;/UserList&amp;gt;}&amp;lt;/Box&amp;gt;;
};

export default HomeComponent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;at this stage we want to have the users data fetched from the Qlik Users API so we can send it as a props to UserList Component. We see that we have three different states, users;which is the data that we will save, loading; to show a spinner while the data is fetched from the server and requestError to show and error message if there is an erorr.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;But hold on, before going to data fetching, we still have some work to do in the UI part.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;header over to component directory and create a new component called 'Footer.tsx'&lt;/p&gt;

&lt;p&gt;and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Box, Text } from '@chakra-ui/layout';

const Footer: React.FC&amp;lt;any&amp;gt; = (): React.ReactElement =&amp;gt; {
  return (
    &amp;lt;Box position="absolute" bottom="0" width="100%"&amp;gt;
      &amp;lt;Text fontSize=".8rem" textAlign="center"&amp;gt;
        &amp;amp;copy; 2021 myCompany
      &amp;lt;/Text&amp;gt;
    &amp;lt;/Box&amp;gt;
  );
};

export default Footer;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are almost there...&lt;/p&gt;

&lt;p&gt;navigate back to 'src/pages.index' and import 'HomeComponent' and 'Footer', render HeaderComponent under Header and then Footer at last. The code should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from 'next/head';
import HomeComponent from '@/Components/HomeComponent';
import Header from '@/Components/Header';
import Footer from '@/Components/Footer';
import { Box } from '@chakra-ui/layout';
import styles from '@/styles/Home.module.css';

export default function Home() {
  return (
    &amp;lt;Box&amp;gt;
      &amp;lt;Head&amp;gt;
        &amp;lt;title&amp;gt;Qlik cloud users&amp;lt;/title&amp;gt;
      &amp;lt;/Head&amp;gt;
      &amp;lt;Header&amp;gt;&amp;lt;/Header&amp;gt;
      &amp;lt;HomeComponent&amp;gt;&amp;lt;/HomeComponent&amp;gt;
      &amp;lt;Footer&amp;gt;&amp;lt;/Footer&amp;gt;
    &amp;lt;/Box&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Awesome, we are done with UI building&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Building the API Connect Functionality
&lt;/h3&gt;

&lt;p&gt;Create a new directory in the root directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;headover to './api' and create a new module called 'connect.ts'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./api/connect.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;inside 'connect.ts', create a string constant with the name of APIKEY that will store the API which you will get from your Qlik tenant account once you have signed for a subscription. You will find this API in your account setting.&lt;/p&gt;

&lt;p&gt;After that, create another string constant that will hold the url of your tenant called apiURL. This URL is unique for your account once you subscribe to the platform.&lt;/p&gt;

&lt;p&gt;so the code should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const APIKEY: string =
  'gf2634985326856r234gbk23daslfbcksagfk9326yrigfcjasjfcksafcbkasbcakccvkasbcksabckasgbkc';

const apiURL: string = 'https://your-tenant.us.qlikcloud.com/api/v1';
```

`

at this stage we are interested to make a call to the API and get the users. In order to call to in an API, we will be using a very nice package called axios, let's and install it:
```
yarn add @axios
```


***We need to understand a concepts here:***

In order to prevent repeating our self and also reuse the API call logic, let's create a nice function that will call the API for as with different url parameter, however, with the same base url.

This function will accept the baseURL and the APIKEY in the headers key, as Authorization type of Bearer.

Now you might be asking, sorry what? yes I got you. just to make your life easier, it's a standard way of calling to any API which requires you some sort authentication via a concept called JSON Token, or your APIKEY, same name. It's basically your password, but not exactly a password, it's some sort of cryptic long character secured letters and number just to verify that you are allowed to make those API request.

You can read about these concepts here:
https://community.auth0.com/t/how-to-use-a-token-with-axios/63171/6

Okay, so the code should look like this:

`

```
import axios from 'axios';

const APIKEY: string =
  'gf2634985326856r234gbk23daslfbcksagfk9326yrigfcjasjfcksafcbkasbcakccvkasbcksabckasgbkc';

const apiURL: string = 'https://your-tenant.us.qlikcloud.com/api/v1';

export const authAxios = axios.create({
  baseURL: apiURL,
  headers: {
    authorization: `Bearer ${APIKEY}`,
  },
});

```

`

Remember we have set the base url to 'https://your-tenant.us.qlikcloud.com/api/v1'

anything that will come after apiURL string, will response a different data, and that's what we want.

you can read more and find about the url structure for the Users API in the following link:
https://qlik.dev/apis/rest/users

Okay great, we are done setting up our API connection, now lets go and make api calls in the HomeComponent component.


###Back to UI, to Make API Calls

Its time to make sense of the UI and API Data. First import authAxios function which we created, in to HomeComponent.

Inside HomeComponent, lets create a function called fetchUsers with the following code:

`

```
  const fetchUsers = useCallback(async () =&amp;gt; {
    setLoading(true);
    try {
      const users = await authAxios(`${apiURL}/users`);
      setUsers(data);
      setLoading(false);
    } catch (e) {
      setRequestError(e.message);
    }
  }, []);
```

`

this is an asynchronous function that uses useCallback hook just to cache the data. It's main functionality is to to make a request '/users' end point and return the response using await keyword.

the response and data schema looks like following:
`

```
{
  "links": {
    "self": {
      "href": "string"
    },
    "next": {
      "href": "string"
    },
    "prev": {
      "href": "string"
    }
  },
  "data": [
    {
      "id": "string",
      "tenantId": "string",
      "subject": "string",
      "status": "active",
      "inviteExpiry": 0,
      "name": "string",
      "created": "2021-10-04T22:43:51.472Z",
      "lastUpdated": "2021-10-04T22:43:51.472Z",
      "picture": "string",
      "email": "string",
      "roles": [],
      "zoneinfo": "string",
      "locale": "string",
      "preferredZoneinfo": "string",
      "preferredLocale": "string",
      "links": {
        "self": {
          "href": "string"
        }
      }
    }
  ]
}
```

`


this is the response from the api call. At this moment we are interested in data key, which an array of object of users information.

We then update our state, so we can render the data into UI.

the final code should like the following:
`

```
import React, { useState, useEffect, useCallback } from 'react';
import UserList from './UserList';
import { Box } from '@chakra-ui/layout';
import { authAxios, apiURL } from 'api/connect';


const HomeComponent: React.FC&amp;lt;any&amp;gt; = (): React.ReactElement =&amp;gt; {
  const [usersData, setUsers] = useState&amp;lt;object[]&amp;gt;([]);
  const [loading, setLoading] = useState&amp;lt;null | boolean&amp;gt;(null);
  const [requestError, setRequestError] = useState&amp;lt;string&amp;gt;('');

  const fetchUsers = useCallback(async () =&amp;gt; {
    setLoading(true);
    try {
      const users = await authAxios(`${apiURL}/users`); 
      setUsers(users.data);
      setLoading(false);
    } catch (e) {
      setRequestError(e.message);
    }
  }, []);

  useEffect(() =&amp;gt; {
    fetchUsers();
  }, []);

  return &amp;lt;Box&amp;gt;{!loading &amp;amp;&amp;amp; &amp;lt;UserList users={usersData}&amp;gt;&amp;lt;/UserList&amp;gt;}&amp;lt;/Box&amp;gt;;
};

export default HomeComponent;

```

`

### Configuring for the PWA installable

We have a last thing to do, in order to make this app a valid pwa application, we need to add a manifest.json configuration file that in the public directory of nextjs app.

the manifest.json contains the following configuration:
`

```
{
    "name": "dashboard",
    "short_name": "dash app",
    "icons": [
      {
        "src": "/icon.svg",
        "sizes": "1024x1024 any",
        "type": "image/svg"
      }
    ],
    "theme_color": "#FFFFFF",
    "background_color": "#29A6A6",
    "start_url": "/",
    "display": "fullscreen",
    "orientation": "portrait"
  }
```

`

by adding this configuration, your app will be installable in any supported chrome devices, it will be have as native mobile app.


#Conclusion

The aim of this application was to showcase, how to build a simple application around Qlik Powerful and smart based on AI and Machine learning platform APIs. There are a lot of great information that is right there for you to use and build creative applications. I strongly recommend to start playing with these APIs and the motivation and creativity will come by itself.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
