Skip to content
Gaurav Walia edited this page Apr 4, 2020 · 4 revisions

This tutorial will explain how you can send the Request to our API using Client Side Javascript using AJAX.

const url = "https://treasurejsapi.herokuapp.com/api/v1/search?find=as";
const userAction = async () => {
     const response = await fetch(url);
     let myJson = await response.json(); //extract JSON from the http response
     // do something with myJson
     console.log(myJson); 
}
userAction();

OUTPUT

[
    {
        "description":"Official React bindings for Redux", 
        "docs":"http://caolan.github.io/async/docs.html",
        "github":"https://github.com/caolan/async",
        "name":"ASYNC",
        "other":[],
        "website":"http://caolan.github.io/async/"
    },
    {
        "description":"astroturf lets you write CSS in your JavaScript files without adding any runtime layer, and with your existing CSS processing pipeline.",
        "docs":"",
        "github":"https://github.com/4Catalyzer/astroturf",
        "name":"ASTROTURF",
        "other":[],
        "website":""
     }
]
Clone this wiki locally