Skip to content

Latest commit

 

History

History
 
 

fetching

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Data fetching example

The app that displayed user name through swapi API.

Demo:

Code example:

import * as React from 'react';
import { Page, Frame, StyleSheet, Text, useFetch } from 'react-figma';


export const App = () => {
    const { isLoading, data } = useFetch(`https://swapi.co/api/people/1`);

    return (
        <Frame>
            <Text>{`isLoading: ${(isLoading && 'true') || 'false'}`}</Text>
            <Text>{`Name: ${data && data.name}`}</Text>
        </Frame>
    );
};                                                                                      

How to run