0
0
Rest APIprogramming~10 mins

Batch delete patterns in Rest API - Interactive Code Practice

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

Complete the code to specify the HTTP method for batch delete.

Rest API
fetch('/items', { method: '[1]' })
Drag options to blanks, or click blank then click option'
ADELETE
BGET
CPOST
DPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using GET or POST instead of DELETE for deletion.
2fill in blank
medium

Complete the code to send a JSON array of IDs to delete in the request body.

Rest API
fetch('/items/batch-delete', { method: 'DELETE', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ [1]: [1, 2, 3] }) })
Drag options to blanks, or click blank then click option'
Aids
Bitems
Cdelete
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic keys like 'data' or 'delete' which are unclear.
3fill in blank
hard

Fix the error in the fetch call to correctly send a batch delete request with JSON body.

Rest API
fetch('/items/delete', { method: 'DELETE', body: [1] })
Drag options to blanks, or click blank then click option'
A{ ids: [4, 5, 6] }
B'{ ids: [4, 5, 6] }'
Cids: [4, 5, 6]
DJSON.stringify({ ids: [4, 5, 6] })
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a plain object instead of a JSON string in the body.
4fill in blank
hard

Fill both blanks to create a batch delete function that sends IDs in JSON body and sets headers.

Rest API
function batchDelete(ids) {
  return fetch('/items/batch', {
    method: '[1]',
    headers: { '[2]': 'application/json' },
    body: JSON.stringify({ ids })
  });
}
Drag options to blanks, or click blank then click option'
ADELETE
BContent-Type
CAuthorization
DPOST
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST method or wrong header keys like Authorization.
5fill in blank
hard

Fill all three blanks to implement a batch delete with error handling and JSON response parsing.

Rest API
async function batchDelete(ids) {
  const response = await fetch('/items/batch-delete', {
    method: '[1]',
    headers: { '[2]': 'application/json' },
    body: JSON.stringify({ ids })
  });
  if (!response.[3]) throw new Error('Delete failed');
  return response.json();
}
Drag options to blanks, or click blank then click option'
ADELETE
BContent-Type
Cok
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Checking response.status directly instead of response.ok.