Devinwon / article

0 stars 0 forks source link

json api data #18

Open Devinwon opened 6 years ago

Devinwon commented 6 years ago
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/reqwest/2.0.5/reqwest.js"></script>
    </head>
    <body>
            <h1>Hello there</h1>
            <script >
                var a={}

                reqwest
                ({
                    //where to get data
                    url:"https://swapi.co/api/people/1/",

                    // what type to exchange
                    type:"json",

                    // what methd  
                    method:"get",

                    //data
                    success:function(resp)
                    {
                        a=resp
                    }

                })
            </script>
    </body>
</html>

console a.name a.films[0]