| 12 | // reject means promise has not settled successfully |
| 13 | |
| 14 | async function getData() { |
| 15 | // Simulate getting data from a server |
| 16 | // let x = await fetch('https://jsonplaceholder.typicode.com/todos/1') |
| 17 | |
| 18 | let x = await fetch('https://jsonplaceholder.typicode.com/posts', { |
| 19 | method: 'POST', |
| 20 | body: JSON.stringify({ |
| 21 | title: 'foo', |
| 22 | body: 'bar', |
| 23 | userId: 1, |
| 24 | }), |
| 25 | headers: { |
| 26 | 'Content-type': 'application/json; charset=UTF-8', |
| 27 | }, |
| 28 | }) |
| 29 | let data = await x.json() |
| 30 | return data |
| 31 | } |
| 32 | |
| 33 | async function main(){ |
| 34 | console.log("Loading modules") |