Using Cloud function for Web3 API in REACT

Hi guys,

I am putting together a quick project that simply uses the ERC20 token price API from Moralis…

I’m building my project with React… and for some reason, having such a hard time using the cloud function and calling it from within my REACT app…

can someone just put it in layman’s terms how I would put together a simple API fetch for a token’s price, and call that function from within my REACT app…


Maybe this post helps you, it has a Python example to get the price: Error 'function' object has no attribute 'swagger_types'

You could get the price with a simple GET request (Python example):

def get_price(address, chain, chain_name):
    provider = '' % address

    headers = {
        "Content-Type": "application/json",
        "X-API-Key": "<YOUR_API_KEY_HERE>"
    statusResponse = requests.request("GET", provider, headers=headers)
    data = statusResponse.json()
    print(json.dumps(data, indent=4))
    print("price =", data['usdPrice'])

unfortunately this still doens’t make sense. they say it’s really easy to make an API call using the cloud… it’s just not at all - unless someone can tell me a step by step process on how I would go about suing this feature

The example that I gave doesn’t use Moralis API with a Moralis server, it only does a http request where. you need an API key.
You can also look at YouTube videos on how to use react with Moralis, like: