MCPcopy Create free account
hub / github.com/CodeWithHarry/Sigma-Web-Dev-Course / getData

Function getData

Video 76/script.js:14–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12// reject means promise has not settled successfully
13
14async 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
33async function main(){
34 console.log("Loading modules")

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected