const URL = 'https://jsonplaceholder.typicode.com/users'
const request = (method, url, body = null) =>{
return fetch(url, {
method: method,
body: body
}).then(request => {
return request.json()
})
}
a = request('GET', URL).then(data =>{
return data
})
console.log(a )
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="fetch.js"></script>
</body>
</html>