new class js -advanced
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
async function fetchUsers() {
|
||||
try {
|
||||
const response = await fetch('https://dummyjson.com/users');
|
||||
const data = await response.json();
|
||||
console.log(data.users);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// Call the function
|
||||
fetchUsers();
|
||||
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
const book = {
|
||||
title: 'The Great Gatsby',
|
||||
author: 'F. Scott Fitzgerald',
|
||||
year: 1925,
|
||||
};
|
||||
|
||||
const jsonString = JSON.stringify(book);
|
||||
console.log(jsonString);
|
||||
|
||||
const jsonObject = JSON.parse(jsonString);
|
||||
console.log(jsonObject.title);
|
||||
console.log(jsonObject.author);
|
||||
Reference in New Issue
Block a user