# How can I use Fetch JSON Plugin

**URL:** <https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243>\
**Category:** Ask for Help\
**Tags:** custom-code\
**Created:** [January 15, 2022, 10:35pm UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243 "2022-01-15T22:35:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![BABAPAPA](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/babapapa/32/29231_2.png) [@BABAPAPA](https://community.glideapps.com/u/BABAPAPA)\
**Post date:** [January 15, 2022, 10:35pm UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/1 "2022-01-15T22:35:23Z")

</div>

I have tried following the example of Plugin Fetch JSON and found that it works like the example provided.

But when I experimented with other links returned an empty result. I want to know why this is the case.

[worldtimeapi.org/api/timezone/Asia/Tokyo](http://worldtimeapi.org/api/timezone/Asia/Tokyo)

 ![fetch](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/e/ce8bdfb11576deb130b18b07cf2dc5c50f01a2d4.png)

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [January 16, 2022, 12:15am UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/2 "2022-01-16T00:15:10Z")

</div>

You should always use https instead of http for fetching APIs from Glide, just to be sure.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/7/97931c4d8d02a036392297f23fe14320138bc7d9.png)

---

<div class="post-metadata">

**Author:** ![BABAPAPA](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/babapapa/32/29231_2.png) [@BABAPAPA](https://community.glideapps.com/u/BABAPAPA)\
**Post date:** [January 16, 2022, 8:32pm UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/3 "2022-01-16T20:32:33Z")

</div>

Thank you for the advice @ThinhDinh  
I still have a few questions.

I’ve tried building an API from FastAPI using Heroku’s host.  
After building I tried running it through Browser.  
I think it should work normally.

[https://myapi1123344.herokuapp.com/joke/](https://myapi1123344.herokuapp.com/joke/)  
[https://myapi1123344.herokuapp.com/book/](https://myapi1123344.herokuapp.com/book/)

But when applied to columns, it doesn’t show any results.

 ![fetch2](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/8/d804839a30d887ee057047e8ac90e9c18671047f.png)

Do you have any advice for me?

This is my main.py

```auto
from typing import Optional
from fastapi import FastAPI
app = FastAPI()
book_db = [
    {
        "title":"The C Programming",
        "price": 720
    },
    {
        "title":"Learn Python the Hard Way",
        "price": 870
    },
    {
        "title":"JavaScript: The Definitive Guide",
        "price": 1369
    },
    {
        "title":"Python for Data Analysis",
        "price": 1394
    },
    {
        "title":"Clean Code",
        "price": 1500
    },
]
joke_db = [
    {
        "id":487,
        "joke":"No statement can catch the ChuckNorrisException.",
        "categories":["nerdy"]
    },
    {
        "id":176,
        "joke":"According to Einstein's theory of relativity, Chuck Norris can actually roundhouse kick you yesterday.",
        "categories":[]
    },
    {
        "id":536,
        "joke":"Don't worry about tests, Chuck Norris's test cases cover your code too.",
        "categories":["nerdy"]
    }
]
@app.get("/")
def read_root():
    return {"Hello": "Worldbb"}
@app.get("/book/")
async def get_books():
    ans = {"type":"success","value":book_db}
    return ans
@app.get("/joke/")
async def get_jokes():
    ans = {"type":"success","value":joke_db}
    return ans

```

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [January 17, 2022, 12:22am UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/4 "2022-01-17T00:22:02Z")

</div>

I have no idea how FastAPI and Heroku would integrate with Glide, but in my experience, if clicking the link would generate some response then it’s either a CORS problem or that it took too much time (more than the timeout set by Glide?) to generate a response in the app.

---

<div class="post-metadata">

**Author:** ![BABAPAPA](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/babapapa/32/29231_2.png) [@BABAPAPA](https://community.glideapps.com/u/BABAPAPA)\
**Post date:** [January 17, 2022, 11:51am UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/5 "2022-01-17T11:51:05Z")

</div>

@ThinhDinh Thank you very much.

---

<div class="post-metadata">

**Author:** ![George-Glide](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george-glide/32/22384_2.png) [@George-Glide](https://community.glideapps.com/u/George-Glide)\
**Post date:** [January 17, 2022, 2:04pm UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/6 "2022-01-17T14:04:50Z")

</div>

The plugin does not handle JSON arrays. You could try something with the JQuery part of it but frankly, I am not an expert at JSON so don’t know what to tell you there. Here is a list of other free APIs that return JSON. Maybe by looking at a few others that do work you may be able to structure your return JSON to something that does work.

> **[Big List of Free and Open Public APIs (No Auth Needed) \[2022\]](https://mixedanalytics.com/blog/list-actually-free-open-no-auth-needed-apis/)**
>
> An API (Application Programming Interface) allows you to send requests to a remote data set, like querying a database. The response will then be delivered back to your own application in a…

---

<div class="post-metadata">

**Author:** ![BABAPAPA](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/babapapa/32/29231_2.png) [@BABAPAPA](https://community.glideapps.com/u/BABAPAPA)\
**Post date:** [January 17, 2022, 2:09pm UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/7 "2022-01-17T14:09:40Z")

</div>

Thank you very much

---

<div class="post-metadata">

**Author:** ![BABAPAPA](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/babapapa/32/29231_2.png) [@BABAPAPA](https://community.glideapps.com/u/BABAPAPA)\
**Post date:** [January 17, 2022, 2:45pm UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/8 "2022-01-17T14:45:22Z")

</div>

@George-Glide  
I choose [Bored](https://www.boredapi.com/) Activity suggestions [https://www.boredapi.com/api/activity](https://www.boredapi.com/api/activity)  
from your example.  
This is result  
{“activity”:“Write a poem”,“type”:“recreational”,“participants”:1,“price”:0,“link”:"",“key”:“8688620”,“accessibility”:0}

 ![fetch4](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/e/be10bbffb4c740ee6446fd8493029e768340174c.png)

I put it into my FastAPI but result still empty.

 ![fetch3](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/e/2e88c53bd4155aae1b79a80b2a4bb5c61919ea0d.png)

@david I saw your api [https://cat-fact.herokuapp.com/facts](https://cat-fact.herokuapp.com/facts)  
I want to know How you setting your api using with Glide App?

---

<div class="post-metadata">

**Author:** ![BABAPAPA](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/babapapa/32/29231_2.png) [@BABAPAPA](https://community.glideapps.com/u/BABAPAPA)\
**Post date:** [January 18, 2022, 10:23pm UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/9 "2022-01-18T22:23:32Z")

</div>

Thank you @ThinhDinh

```auto
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins=['*']
)

@app.get('/')
def read_main():
    return {'message': 'Hello World!'}

```

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [January 19, 2022, 12:15am UTC](https://community.glideapps.com/t/how-can-i-use-fetch-json-plugin/37243/10 "2022-01-19T00:15:04Z")

</div>

This solved the CORS problem? Sweet!
