17 lines
367 B
JavaScript
17 lines
367 B
JavaScript
'use strict';
|
|
|
|
async function fetchData() {
|
|
try {
|
|
const response = await fetch('https://dummyjson.com/posts');
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
const data = await response.json();
|
|
console.log(data);
|
|
} catch (error) {
|
|
console.error('Problem with the fetch operation:', error);
|
|
}
|
|
}
|
|
|
|
fetchData();
|