0
0
Node.jsframework~10 mins

HTTP methods and CRUD mapping in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to use the HTTP method for creating a new resource.

Node.js
app.[1]('/items', (req, res) => { res.send('Create item'); });
Drag options to blanks, or click blank then click option'
AGET
BPOST
CPUT
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET instead of POST
Using DELETE to create resources
2fill in blank
medium

Complete the code to use the HTTP method for reading a resource.

Node.js
app.[1]('/items/:id', (req, res) => { res.send('Read item'); });
Drag options to blanks, or click blank then click option'
APOST
BPUT
CPATCH
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST to read data
Using DELETE to read data
3fill in blank
hard

Fix the error in the code by choosing the correct HTTP method for updating a resource.

Node.js
app.[1]('/items/:id', (req, res) => { res.send('Update item'); });
Drag options to blanks, or click blank then click option'
APUT
BPOST
CGET
DDELETE
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST to update
Using GET to update
4fill in blank
hard

Fill both blanks to handle partial updates and deletions of a resource.

Node.js
app.[1]('/items/:id', (req, res) => { res.send('Partial update'); });
app.[2]('/items/:id', (req, res) => { res.send('Delete item'); });
Drag options to blanks, or click blank then click option'
APATCH
BPOST
CDELETE
DPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using PUT for partial updates
Using POST for deletion
5fill in blank
hard

Fill all three blanks to complete the CRUD operations with correct HTTP methods.

Node.js
app.[1]('/items', (req, res) => { res.send('Create item'); });
app.[2]('/items/:id', (req, res) => { res.send('Read item'); });
app.[3]('/items/:id', (req, res) => { res.send('Delete item'); });
Drag options to blanks, or click blank then click option'
APOST
BGET
CDELETE
DPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing GET and POST
Using PUT for deletion