Quiz 1-10

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is axios and what is its purpose?

What: API method for server side (jQuery for server side) Purpose: To have API requests from server side OR keep API keys safe on server side

2. Which of the following HTML tags can have inner html? (check as many as apply) a. <a> b. <br> c. <div> d. <h1> e. <img> f. <p>

a. <a> c. <div> d. <h1> f. <p>

10. What is a method? w/ example

have parantheses, action happens connection.execute()

What is an event? w/ example

have parantheses, action waits to happen document.ready() $("#action").click()

Write a GET supporting function for getUsertest "Issue a GET against usertest and send the key userid." + " The JSON response will contain all user attributes that correspond to that userid.",

let getUsertest = async (res,query) => { let userid = query.userid; //error trap if ( userid == undefined || userid == "" || isNaN(userid) ){ return formatres(res,"The key userid was missing or incorrect.",400); } try { //SQL work and return the result let txtSQL = 'select * from users where userid = ?'; //bug here! let [result] = await connection.execute(txtSQL,[userid]); //success!! return formatres(res,result,200); } catch(e){ return formatres(res,e,500); // good for testing //return formatres(res,"Unexpected Error",500); //production } }

Write a listeing response

let larry = () => { $.ajax({ url : "https://misdemo.temple.edu/stooges/larry", method : "GET", success: (result)=>{ $("#output").append(result); $("#output").append("<br>"); $("#larrydone").val("ok"); $("#larrydone").change(); }, error: (data)=>{ console.log(data); } }); } $("#larrydone").change(()=>{ moe(); });

Write an async response:

let oneBigFunction = async () => { //first we call larry await $.ajax({ url : "https://misdemo.temple.edu/stooges/larry", method : "GET", success: (result)=>{ $("#output").append(result); $("#output").append("<br>"); }, error: (data)=>{ console.log(data); } });

Write a POST supporting function for postUsertest "Issue a POST against usertest and send username, password, email, usertype, firstname, lastname. " + " The JSON response will be the userid that was created by the POST.",

let postUsertest = async (res,body) => { let username = body.username; let password = body.password; let email = body.email; let usertype = body.usertype; let firstname = body.firstname; let lastname = body.lastname; //error trap if ( username == undefined || username == "" ){ return formatres(res,"The key username was missing or incorrect.",400); } if ( password == undefined || password == ""){ return formatres(res,"The key password was missing or incorrect.",400); } if ( email == undefined || email == "" ){ return formatres(res,"The key email was missing or incorrect.",400); } if ( usertype == undefined || usertype == ""){ return formatres(res,"The key usertype was missing or incorrect.",400); } if ( firstname == undefined || firstname == ""){ return formatres(res,"The key firstname was missing or incorrect.",400); } if ( lastname == undefined || lastname == "" ){ return formatres(res,"The key lastname was missing or incorrect.",400); } //SQL work and return the result try{ let txtSQL = 'insert into users(username, password, email, usertype, firstname, lastname) values (?,?,?,?,?,?)'; let [result] = await connection.execute(txtSQL,[username, password, email, usertype, firstname, lastname]); return formatres(res,result.insertId,200); } catch (e){ //return formatres(res,"Unexpected Error",500); return formatres(res,e,500); } }

3. <ul> <li id = "pet01" class="dog">Spot</li> <li id = "pet02" class="dog">Fido</li> <li id = "pet03" class="dog">Puddles</li> <li id = "pet04" class="cat">Mittens</li> <li id = "pet05" class="cat">Whiskers</li> </ul> Write a single jQuery command that will make all the tags containing the names of cats invisible. does

$(".cat").hide()

3. The following jQuery methods can be used to make API calls. Which one is the most generic? (That is, it can be used for the widest variety of tasks?) $.ajax $.get $.getJSON $.post $.xml

$.ajax

4. To sort a list of students in descending order by last name, you can use this statement: A. SELECT FirstName, LastName FROM Student ORDER BY LastName DESC; B. SELECT FirstName, ORDER BY LastName DESC; C. SELECT FirstName, LastName FROM Student ORDER BY LastName; D. SELECT FirstName, LastName FROM Student WHERE ORDER BY LastName DESC;

A. SELECT FirstName, LastName FROM Student ORDER BY LastName DESC;

4. What is the correct order of clauses in an SQL query that includes WHERE? A. SELECT, FROM, WHERE B. WHERE, SELECT, FROM C. SELECT, WHERE, FROM D. FROM, WHERE, SELECT

A. SELECT, FROM, WHERE

1. Improving the accessibility of a web application usually improves the usability of the application for all users, regardless of their ability / disability. A. True B. False

A. True

6. Practically speaking, RESTful systems use the HTTP protocol and its conventions. A. True B. False

A. True

6. Recall that one of the REST constraints is that RESTful systems should have a tiered architecture. This means that a client-side developer should not need to know any technical details about the systems "behind" the web service. A. True B. False

A. True

3. Which of the following are referred to as contextual classes in Bootstrap? (Check as many as apply.) A. btn-success B. alert-danger C. container-fluid D. container E. row F. btn-warning G. col-md-8

A. btn-success B. alert-danger F. btn-warning

3. Of the three kinds of files in a web application which one serves as the "parent" ... that is it contains references that include (or "pull in") the other two kinds of files? A. html B. css C. js D. app

A. html

8. What statement best describes insertId as mentioned in the last question? A. insertId is an attribute of the result object B. insertId is a method of the result object C. insertId is an event of the result object D. insertId is either an event or a method of the result object

A. insertId is an attribute of the result object

8. Which of the following is true regarding jQuery? A. jQuery statements only run on the client. jQuery is a client-side library. B. jQuery statements only run on the server (in lambda). jQuery is a server-side library. C. jQuery statements work on both client and server-side code.

A. jQuery statements only run on the client. jQuery is a client-side library.

8. In our endpoint template, where are we most likely to see error trapping and database operations? A. supporting functions B. routing function C. event handler D. all of the above

A. supporting functions

4. The "Items" table has one "Name" column with 12 items in it. What will this query return? SELECT 'Name' FROM Items; (There are no back quotes in this question.) A. the text "Name" showing 12 time B. the values of all 12 items C. the text "Name" showing once D. the text "Items" showing once

A. the text "Name" showing 12 time

Is async or sync code faster?

Async - JS is a non blocking language so the script does not wait for outside resources to finish while sync does

3. Read the follow statements about the async / await commands in JavaScript. A) The async command(s) must be nested inside a function defined with await. B) The await command(s) must be nested inside a function defined with async. C) We use these commands to ensure that 2 or more API calls take place in asynchronous (fast, but unpredictable) order. D) We use these commands to ensure that 2 or more API calls take place in synchronous (lockstep) order. Which of the following is true? A and C A and D B and C B and D

B and D

2. Which of the following is a function expression? A) function foo(a,b){ return a - b; } B) let foo = function(a,b){ return a - b; }

B) let foo = function(a,b){ return a - b; }

7. Which of the following is true about libraries? A. All of the above B. A library can be used to reference an API C. A library prescribes one or more approaches to building software D. A library often contains a framework

B. A library can be used to reference an API

7. Think of how .execute is used with the mysql2 connection object. Like this: let results = connection.execute(txtSQL, [x,y,z]) What is .execute? A. A library B. A method of the connection object C. An attribute of the connection object D. An event of the connection object

B. A method of the connection object

7. Think of how .click() is used in client-side code. Like this: $("#button").click(function(){}); What is click? A. An attribute B. An event C. A method D. An object

B. An event

9. Which of the following portions of code will contain jQuery statements? A. Routing function B. Client-Side Controller C. Event Handler (on Lambda) D. Supporting Function (on Lambda)

B. Client-Side Controller

1. Every HTML img tag, including decorative images, must have an alt text attribute with (at the very least) one or two words of descriptive text. Under no circumstances should you set the alt attribute to an blank (empty string) value. A. True B. False

B. False

1. Improving the color contrast of text only benefits users with vision impairments. A. True B. False

B. False

6. RESTful systems tend to me more secure than other system architectures. This is the primary advantage of RESTful systems. A. True B. False

B. False

6. Systems that follow REST conventions are designed so that clients will maintain a regular, constant, heartbeat connection to one or more servers. Each new client connection is allocated a small portion of the server's memory. A. True B. False

B. False

8. Consider the following line of code: let [result] = connection.execute(txtSQL,[53]); Which of the following is true? A. If txtSQL holds a valid INSERT statement, then result.insertId will have the value 53. B. If txtSQL holds a valid INSERT statement, then result.insertId will have the value of the primary key that was just created. C. If txtSQL holds a valid SELECT statement, then result.insertId will have the value 53. D. If txtSQL holds a valid SELECT statement, then result.insertId will have the value of last primary key that was read.

B. If txtSQL holds a valid INSERT statement, then result.insertId will have the value of the primary key that was just created.

1. Your coworker, Mildred, proclaims that visually impaired users can use screen-readers, consequently no accessibility updates need to be made to the company web site. A. Mildred is probably right. Screen readers like JAWS and NVDIA are very advanced and rely on artificial intelligence to read web pages. B. Mildred is probably wrong. Even the best screen readers rely on the existence of HTML tags. Human content creators need to use those tags correctly.

B. Mildred is probably wrong. Even the best screen readers rely on the existence of HTML tags. Human content creators need to use those tags correctly.

6. Dudley goes on to insist that the only documentation for the new web service should be stored as a pdf document on the company intranet. That way, only the right people will know how to use it. Without that documentation, all the features of the Web Service will be unusable by any developer. Is this practice RESTful? A. Yes B. No

B. No

7. Read the following definition: "A data construct that provides a description of something that may be used by a computer." What is it a definition of? A. Framework B. Object C. API D. Protocol E. Library F. Architectural style

B. Object

6. In which HTTP method should not be considered "safe" to initiate the same request over an over again? (That is, which method is not idempotent?) A. GET B. POST C. PUT D. DELETE

B. POST

9. Sometimes, a duplicate Ajax call can be made very quickly, by accident. (Imagine a user clicking on a button several times impatiently!) Which of the following HTTP methods should *not* considered safe to execute over and over again? A. DELETE B. POST C. GET D. PUT E. PATCH

B. POST

7. Read the following definition: "A set of rules governing the exchange or transmission of data between devices." What is it a definition of? A. Architectural style B. Protocol C. API D. Library E. Framework F. Object

B. Protocol

4. This statement will return a row for every row in the Users table, and also associated information from the Events table if there is any. A. SELECT * FROM users RIGHT JOIN events ON events.eventid = events.createdby; B. SELECT * FROM users LEFT JOIN events ON events.createdby = users.userid; C. SELECT * FROM events WHERE events.createdby = users.userid; D. SELECT * FROM users;

B. SELECT * FROM users LEFT JOIN events ON events.createdby = users.userid;

6. Which, by its very nature, is more secure? A. Client-Side Code B. Server-Side Code

B. Server-Side Code

9. In our class template, what does the variable "res" represent? A. The HTTP resource B. The HTTP response C. The HTTP resurrection D. The HTTP result

B. The HTTP response

1. What kind of value is assigned to "for"? A. The name of an input tag B. The id of an input tag C. A meaningful description of the tag D. A meaningful description of the web page

B. The id of an input tag

3. When creating a web application it is a common practice to split the JavaScript, HTML and CSS out into separate files. Why is this done? (Choose the best answer.) A. To improve the application's security B. To make the code easier to manage and maintain. C. To improve the application's performance D. To give programmers job security

B. To make the code easier to manage and maintain.

4. Select the WHERE clause that returns all records with the text "priority" in the Comment column. A. WHERE Comment = '%priority%' B. WHERE Comment LIKE '%priority%' C. WHERE Comment LIKE 'priority%' D. WHERE Comment LIKE 'priority' E. WHERE Comment LIKE '%priority'

B. WHERE Comment LIKE '%priority%'

2. Recall that methods and events are different things. Which of the following is a jQuery event? A. .addClass B. .append C. .click D. .html E. .removeClass F. .val

C. .click

9. What is the big difference between "Basic" and "Advanced" Web Service features as we have defined them in this class? A. Basic features expect data to be received as URL encoded data. Advanced features expect data to be received as JSON. B. Basic web services use "GET". Advanced web services use both "GET" and "POST". C. Advanced Web Service features will use Try/Catch blocks to correctly implement HTTP status codes of 500 D. Advanced features interact with a database using the mysql2 connection object. Basic features do not.

C. Advanced Web Service features will use Try/Catch blocks to correctly implement HTTP status codes of 500

8. Two developers are working on a project. Bob is responsible for the client side code, and Sally is responsible for the Web Service (lambda) code. They have a problem with their solution. Bob says its Sally's fault. Sally says its Bob's fault. What should they do? A. Ask their manager for help. B. Ask ChatGPT for help. C. Change all the variable names in their code to that everything matches. Check each one of Sally's web service features using ThunderClient in VS Code. If they all work as expected, then the problem is on the client side. D. Check each one of Sally's web service features using ThunderClient in VS Code. If they all work as expected, then the problem is on the server (lambda) side.

C. Change all the variable names in their code to that everything matches. Check each one of Sally's web service features using ThunderClient in VS Code. If they all work as expected, then the problem is on the client side.

3. We have a web application, and we observe that the position of box B changes when the user views the page in a different orientation. How would we (commonly) describe such behavior? A. This is the "Hilda Hack" ... a CSS trick used to make pages responsive B. Automagic Design Layout C. Float Drop (part of a responsive layout) D. Font Drop (part of a responsible layout) E. A fixed layout (because the design automatically fixes itself)

C. Float Drop (part of a responsive layout)

7. Identify the protocols. (Check as many as apply.) A. HTML B. NodeJS C. HTTP D. TCP/IP E. Express F. REST

C. HTTP D. TCP/IP

8. In our endpoint template, we have three major sections of code: supporting functions, routing function, HTTP event handler. When processing an incoming HTTP request, what sequence do these operate it? A. supporting function, routing function, HTTP event handler B. HTTP event handler, supporting function, routing function C. HTTP event handler, routing function, supporting function D. routing function, supporting function, HTTP event handler E. routing function, HTTP event handler, supporting function

C. HTTP event handler, routing function, supporting function

1. Which is true about the HTML title tag? A. It is a self-closing tag B. It usually appears inside the <body> of an HTML document C. It is the first tag read by a screen reader D. It is usually OK to leave the content of the title tag blank or omit the tag entirely

C. It is the first tag read by a screen reader

9. I just executed this line of code. The variable txtSQL holds a valid SQL INSERT statement. What is the best way to determine the primary key of the record I just created? let [result] = connection.execute(txtSQL,["Moe","Howard"]); A. Issue a SELECT using "Moe" and "Howard" in the criteria. Use a subselect to identify the maximum primary key. B. Look at the method result.insertId() C. Look at the attribute result.insertId D. Issue a SELECT using "Moe" and "Howard" in the criteria. Use "ORDER BY" and "LIMIT" to identify the maximum primary key.

C. Look at the attribute result.insertId

6. What is term REST short for? A. Recursive Serialized Transmission B. Responsive Extended Static Text C. Representational State Transfer D. Regular Expression Syntax Testing

C. Representational State Transfer

4. Your student table contains student records from California (CA), Georgia (GA), New Hampshire (NH) and New York (NY). Choose the correct statement that returns the students from all states except New York. A. SELECT FirstName, LastName FROM Student WHERE State >= 'NY'; B. SELECT FirstName, LastName FROM Student WHERE State IS 'CA' AND NOT 'NY'; C. SELECT FirstName, LastName FROM Student WHERE State != 'NY'; D. SELECT FirstName, LastName FROM Student WHERE State = 'CA', 'GA', 'NH';

C. SELECT FirstName, LastName FROM Student WHERE State != 'NY';

9. Following the endpoint template we use in this class, where in your (lambda) server-side code should students write error trapping code? A. There is no error trapping on the server side. All the error trapping is done on the client. B. Event Handler C. Supporting Function D. Routing function

C. Supporting Function

3. Look at the code below. When this code is evaluated by a browser, what color will the box be? <html> <head> <style> div { background-color: green; } #thebox { height:20px; width:20px; background-color: red; } .bluebox { background-color: blue !important; } </style> </head> <body> <div id="thebox" class="bluebox" style="background-color: purple;" ></div> </body> </html> A. green B. red C. blue D. purple

C. blue

3. You are on a web development project with your co-worker, Skippy. You, Skippy and everyone in the office uses the Chrome Browser and Windows laptops. Skippy has made a number of changes to the web application's code in the "js" folder of the project. Skippy is frustrated and says that none of his changes are being detected in the browser. What should skippy do? A. ctrl-alt-delete B. ctrl-x and ctrl-v C. ctrl-shift-r D. consider a new line of work

C. ctrl-shift-r

8.In our endpoint template, where do we see the res (response) object declared? A. supporting functions B. routing function C. event handler D. none of the above

C. event handler

9. Which of the following methods transmit data primarily in the query string? (CHECK AS MANY AS APPLY) A. DELETE B. PUT C. PATCH D. POST E. GET

E. GET

2. In JavaScript, what is the purpose of => operator? A. Assignment B. Comparison (test for inequality) C. Comparison (test for greater than or equal to) D. Comparison (test for less than or equal to) E. It indicates the definition of a function

E. It indicates the definition of a function

6. You are working on a web and mobile development project. Your coworker (let's call him, Dudley) suggests that a web service be created to create a user profile. Dudley proposes that the web service use the following pattern: http://api.some-project.com/profile?action=ADD&username=polly Is Dudley's proposal consistent with RESTful practices? A. Yes, because it uses http. B. Yes, because it uses URL encoded data. C. No. It must use https to be RESTful. D. No. The URL must specify the port number to be RESTful. E. No. It is using the GET method for what should be a POST. F. No. It is using the POST method for what should be a GET.

E. No. It is using the GET method for what should be a POST.

6. Who coined the term REST and proposed the six constraints of REST? A. Roy Rogers B. Ray Bradbury C. Tim Berners-Lee D. John Resig E. Roy Fielding F. Al Gore

E. Roy Fielding

1. Which of the following disabilities should developers consider when creating a user interface? A. Mobility disabilities B. Color Blindness C. Auditory disabilities D. Low vision E. Blindness F. All of the above

F. All of the above

9. In the following line of code, what is execute? let [result] = connection.execute(txtSQL,["Moe","Howard"]); A. It is an attribute of the HTTP connection object. B. It is an attribute of the database connection object. C. It represents the HTTP query string. D. It is a method of the HTTP connection object. E. It represents a jQuery object. F. It is a method of the database connection object.

F. It is a method of the database connection object.

6. Consider the status code of 404 - "Page could not be displayed". Where is this code used to represent the fact that "the page could not be displayed"? A. Temple University B. Google C. Microsoft D. Apple E. The U.S.A. F. The U.S.A. and Europe G. English speaking countries H. Everywhere on the world wide web

G. Everywhere on the world wide web

Write an INSERTstatement

INSERT INTO (table name) (field 1, field2...) VALUES (value 1, value 2...)

What does it mean that Javascript is a non-blocking language?

JS is executed top down. When we call a reource that is outside the script (API) the script will not wait and keep executing - the script will not be "blocked".

Write a callback response:

//then we call moe let moe = () => { $.ajax({ url : "https://misdemo.temple.edu/stooges/moe", method : "GET", success: (result)=>{ $("#output").append(result); $("#output").append("<br>"); curly(); }, error: (data)=>{ console.log(data); } }); }

7. Which of the following is true about APIs? (Check as many as apply) A. Some APIs are referenced using the src attribute of the script tag B. Some APIs are built into the browser. C. You must use jQuery if you want to use an API D. Some APIs are implemented over HTTP

A, B, D

2. In JavaScript, what operator does "double duty"? (That is, it serves more than one purpose?) A. + B. - C. * D. / E. = F. == G. ++

A. +

2. jQuery has a method named .val(). The .val() method is most commonly used with which of the following HTML tags? A. <input> B. <div> C. <p> D. <a>

A. <input>

7. Which of the following best describes Bootstrap? A. Framework B. Architecture C. Library D. Object

A. Framework

8. In the MIS3502 endpoint template, what is the true of the variable res? (CHECK ALL THAT APPLY) A. It gets passed from function to function. B. It is a JSON object that holds response headers, a body and a status code. C. It is like an envelope that gets filled with data and sent back to the client. D. The name "res" is short for response.

A. It gets passed from function to function. B. It is a JSON object that holds response headers, a body and a status code. C. It is like an envelope that gets filled with data and sent back to the client. D. The name "res" is short for response.

1. In the HTML language, what is "for"? A. It is an attribute of a label tag B. It is an attribute of an img tag C. It is a self-closing tag D. It is a tag E. It is the number after "three"

A. It is an attribute of a label tag

9. Which of the following portions of code is nothing more than a long list of conditional statements? A. Routing function B. Supporting Function C. Event Handler D. Client-Side Controller

A. Routing function

6. Which of the three HTTP status codes used in this course represents a client-side error?

400

6. Which of the three HTTP status codes used in this course represents a server-side error?

500

2. Which of the following jQuery commands is used to add to (not overwrite) the existing inner HTML of a tag? A. .addClass B. .html C. .val D. .append

D. .append

7. Think of how .html() is used in client-side code. Like this: $("#message").html("Hello World"); What is html? A. An object B. An event C. An attribute D. A method

D. A method

1. What is WCAG? A. Screen reader software B. A set of web accessibility guidelines created by Google C. A set of web accessibility guidelines created by Microsoft D. A set of web accessibility guidelines created by the World Wide Web Consortium (W3C)

D. A set of web accessibility guidelines created by the World Wide Web Consortium (W3C)

1. Which is a benefit of building more accessible web sites / web applications? A. Your product / service is available to broader market B. Improved Search engine optimization (SEO) C. Avoiding costly legal battles and/or allegations of discrimination D. All of the above

D. All of the above

1. Which of the following is true of accessibility? A. It is sometimes abbreviated A11y B. It is the practice of eliminating technological barriers for persons with disabilities C. It is the practice of eliminating technological barriers for persons with socio-economic restrictions. D. All of the above E. None of the above

D. All of the above

3. Refer back to the last question, why are those classes called "contextual"? A. Because the must be placed in an html file. An html file is the correct context. B. Because they must be used in a web application. A web application is the correct context. C. Because they can only be used in mobile applications. A mobile application is the correct context. D. Because the class name conveys the context (the intended meaning) of the CSS styling, not its specific appearance (red, blue, green, etc.).

D. Because the class name conveys the context (the intended meaning) of the CSS styling, not its specific appearance (red, blue, green, etc.).

4. Which data row will be left out with this condition in your statement? WHERE Color!= 'B' OR (Size='L' AND Price>20) A. Color is 'B', Size is 'L' and Price is 30. B. Color is 'W', Size is 'S' and Price is 20. C. Color is 'G', Size is 'L' and Price is 25. D. Color is 'B', Size is 'XL' and Price is 10.

D. Color is 'B', Size is 'XL' and Price is 10.

8. In our endpoint template, where are we most likely to report responses with a status code of 400? A. In the HTTP event handler B. In the routing function C. In "catch" blocks D. In error traps

D. In error traps

9. Which of the following is true of the function called formatres A. It is an essential part of NodeJS B. It is an essential part of Express C. It is an essential part of jQuery D. It is a convenience only

D. It is a convenience only

8. What is formatres? A. It is part of Nodejs. It formats a response to be sent to the client. B. It is part of jQuery. It formats a response to be sent to the cloud. C. It is part of JavaScript. It formats a general purpose response object. D. It is part of the MIS3502 template. It formats a response to be sent to the client.

D. It is part of the MIS3502 template. It formats a response to be sent to the client.

7. Which of the following best describes jQuery? A. Architecture B. Framework C. Object D. Library

D. Library

4. Your SQL statement is returning a ScanDate field. What can you add to it in order to list the dates from latest to earliest? A. ORDER BY ScanDate CURRENT B. ORDER BY ScanDate Now() C. ORDER BY ScanDate ASC D. ORDER BY ScanDate DESC

D. ORDER BY ScanDate DESC

9. In the code sample below, what is "e" short for? try{ // some code here } catch(e){ console.log(e); } A. expression B. event handler C. encryption D. error E. encapsulation

D. error

3. Look at the code below. Yes, it really is different from the code in the last question! Look at the <div> tag!When this code is evaluated by a browser, what color will the box be? <html> <head> <style> div { background-color: green; } #thebox { height: 20px; width:20px; background-color: red; } .bluebox { background-color: blue !important; } </style> </head> <body> <div id="thebox" style="background-color: purple;"></div> </body> </html> A. green B. red C. blue D. purple

D. purple

Write a DELETE statement

DELETE FROM (table name) WHERE (condition)

7. What is the software architectural style that we have learned about all semester long?

REST

Asynchronous code

Running a scrip file w/ outside resources called

Write an UPDATE statement

UPDATE (table name) SET field name = value1... WHERE (condition)

Write a PUT supporting function for putUsertest "Issue a PUT against usertest and send the userid, username, password, email, usertype, firstname, lastname." + " The corresponding user record will be updated with all the new values. "

let putUsertest = async (res,body) => { let userid = body.userid; let username = body.username; let password = body.password; let email = body.email; let usertype = body.usertype; let firstname = body.firstname; let lastname = body.lastname; //error trap if ( userid == undefined || userid == "" || isNaN(userid) ){ return formatres(res,"The key userid was missing or incorrect.",400); } if ( username == undefined || username == "" ){ return formatres(res,"The key username was missing or incorrect.",400); } if ( password == undefined || password == "" ){ return formatres(res,"The key password was missing or incorrect.",400); } if ( email == undefined || email == "" ){ return formatres(res,"The key email was missing or incorrect.",400); } if ( usertype == undefined || usertype == "" ){ return formatres(res,"The key usertype was missing or incorrect.",400); } if ( firstname == undefined || firstname == "" ){ return formatres(res,"The key firstname was missing or incorrect.",400); } if ( lastname == undefined || lastname == "" ){ return formatres(res,"The key lastname was missing or incorrect.",400); } //SQL work and return the result try{ let txtSQL = 'update users set username=?, password=?, email=?, usertype=?, firstname=?, lastname=? where userid = ?'; let [result] = await connection.execute(txtSQL,[username, password, email, usertype, firstname, lastname,userid]); let txtSQL2 = 'select * from users where userid = ?'; let [result2] = await connection.execute(txtSQL2,[userid]); return formatres(res,result2,200); } catch (e){ //return formatres(res,"Unexpected Error",500); return formatres(res,e,500); } }

10. What is an attribute? w/ example

no parantheses, just values res.body() request["httpMethod"] result["insertMethod"]

9. In our class template, the event handler code extracts four important pieces of information from the incoming HTTP request. The code extracts the HTTP method, the data in the body (if any), the data in the query string (if any), and ... what else? What is the fourth thing? (A one word answer is expected here.)

path

Synchonous code

running a script file w/o outside resources called


संबंधित स्टडी सेट्स

CompTIA Cloud+ CV0-003 Practice Questions

View Set

Phrasal Verbs intermediate, gapped sentences

View Set

Pharmacological and Parenteral Therapies Prep U

View Set

STA 115 Test 2 Chp. 7, 8, 11, 12, 14 and 15.

View Set

Chapter 47: Lipid-Loweing Agents

View Set

CCNA 1 v7 Modules 8 - 10: Communicating Between Networks Exam

View Set

Lesson 2 - Period and Group Designations of the Periodic Table

View Set