Skip to content

How can I call my own host API? #1137

Answered by Archmonger
Alan3344 asked this question in Question
Discussion options

You must be logged in to vote

To add on to this answer...

As long as you are trying to fetch data hosted on your local server, you don't need to perform a HTTP API request. Accessing local data in your situation might look something like this:

@component
def example():
    data, set_data = use_state(None)

    @use_effect
    def loading():
        # Data is already set
        if data:
            return
        
        # Need to fetch data
        new_data = [
                UserData(
                    id=i,
                    name=f"test_{i}",
                    age=i,
                    avatar=f"https://avatars.dicebear.com/v2/avataaars/{i}.svg",
                )
                for i in range(10)
        …

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@Archmonger
Comment options

Answer selected by Alan3344
@Alan3344
Comment options

@Archmonger
Comment options

@Alan3344
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants