fetch Flashcards

1
Q

What does fetch() return?

A

A promise that resolves with a Response object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the default request method used by fetch()?

A

The GET method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

You can specify the request method as a value in the “method” property of the “init” parameter object, which is the second parameter passed into “fetch()”.

example: 
fetch('https://example.com/profile', {
  method: 'GET'
})
.then(response => response.json())
.then(data => {
  console.log('Success:', data);
})
.catch((error) => {
  console.error('Error:', error);
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly