Question: Can you complete this code problem? INSTRUCTIONS: Create a function called addPerson in the fetch-post.js file. Inside the function, make a POST request to http://example.com/api/people

Can you complete this code problem?

INSTRUCTIONS:

Create a function called addPerson in the fetch-post.js file.

Inside the function, make a POST request to http://example.com/api/people with the following JSON body:

{ "firstName": "Maul", "lastName": "Kimmerman" }

If you format your request properly, you can expect the body of the response to be:

{ "people": [ { "id": 1, "lastName": "Zimmerman", "firstName": "Paul" }, { "id": 2, "lastName": "Yimmerman", "firstName": "Raul" }, { "id": 3, "lastName": "Limmerman", "firstName": "Caul" }, { "id": 9, "lastName": "Kimmerman", "firstName": "Maul" }, ] }

Return the value of the people key from the addPerson function.

Your objective is to implement the code in fetch-post.js file. Use fetch to make a POST request with a JSON body and return a specific value from the response JSON body.

CODE:

if (!fetch) {
var fetch = require('./test/node-fetch')(1);
}
/**
* Do not change code above this line.
* See README.md for instructions
******************************************************************************/
// Your code here
/*******************************************************************************
* Do not change code below this line.
*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!