The following questions will test our knowledge of what we have just learned:
- What is wrong with the following HTTP POST request using the fetch function?
fetch('http://localhost:17525/api/person', {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: {
firstName: 'Fred'
surname: 'Smith'
}
})
- What is wrong with the following request using the fetch function?
fetch('http://localhost:17525/api/person/1')
.then(res => {
console.log('firstName', res.body.firstName);
})
- What is wrong with the following request using the fetch function?
fetch('http://localhost:17525/api/person/21312')
.then(res => res.json())
.catch(res => {
if (res.status === 404) {
console.log('person not found')
}
});
- We have an endpoint...