Question: can i fill in the gaps with ram - estre . 2002 , Jai | T |ur Question Completion Status: For the purposes of this

with ram - estre . 2002 , Jai | T |ur Question Completion Status: For the purposes of this question you do not need to consider authentication, Complete the JavaScript function addser below. It takes three parameters werData.which you can assume contains all the data that the API needs to be sent to sucessfully create a new user, and on Success and onerror which are functions to be called in the event of a request, respectively, succeeding or falling When called, addoser should request the creation of a new user on the server using the user data it is passed of the request status is 200, it should call the ones function with no arguments. If the request status is not 200, it should call the onrror function with no arguments Fonction addoser userData,onSuccess on tror) var - new XLIITT PRequest() req.open(t/Post tro) roq.setRequestHeader Content-Type, application/son's reg.onload = function() 1t (reg.atatu - 200) 1 1 var data- prepare data to send red.send(data) 1 Click Submit to complete this assessment Question 50s a o a S G 3 15.02 05/01/2001 hop Blachoward Leam Ginton based authentication Gintoken-based authentication X + ston.ac.uk/tr/courses/.29385 1/cl/outline Question Completion Status: The first napoint/api/users/accepts GETrequests, which return JSON data representing an array or air or the site's users, and POST requests which allow you to add a user to the site. The second endpoint (/api/users/:uid/), accepts GET requests, which return JSON data describing a single user with a given ID. and DELETE requests which allow the deletion of a user with a given ID. For the purposes of this question, you do not need to consider authentication. Complete the JavaScript function adduser below. It takes three parameters: userdata.which you can assume contains all the data that the API needs to be sent to sucessfully create a new user, and onSuccess and onError which are functions to be called in the event of a request, respectively, succeeding or failing. When called, adduser should: request the creation of a new user on the server using the user data it is passed, if the request status is 200, it should call the onSuccess function with no arguments. If the request status is not 200, it should call the onError function with no arguments function adduser(userData, on success onerror) var red - new XMLHTTPRequest() req.open true) req.setRequestHeader("Content-Type, application/json): reg.onload = function() if (req.status --- 200) al.se search 0 a WE do function adduser(userData, onSuccess, onError) var req new XMLHTTPRequest(); reg. open ,true) req.setRequestHeader("Content-Type', 'application/json'); req.onload function() { if (req.status 200) { else { 1 var data = prepare data to send req. send (data)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
