Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions hello-world.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import fetch from 'node-fetch';

// URL to fetch sample JSON data
const url = 'https://jsonplaceholder.typicode.com/posts';
const url = 'https://dummyjson.com/users';

async function fetchData() {
try {
const response = await fetch(url);

if (!response.ok) {
throw new Error('Network response was not ok');
}

const data = await response.json();

// Accessing the title of the second post
var demoValue = data[1].title; // Adjust based on fetched data structure
// Accessing the name of the second user
var demoValue = data.users[1].firstName;
console.log(`Demo Value: ${demoValue}`);
console.log("Your environment is setup correctly!")
} catch (error) {
Expand Down