Несколько DELETE запросов сбой сервера - PullRequest
0 голосов
/ 13 октября 2019

Я использую этот поддельный json-сервер API

db.json:

{ "cart": [ { "id": 100, "count": 1 }, { "id": 101, "count": 1 } ] }

запрос:

const url = 'http://localhost:3000/cart/'
const ids = [100, 101]
const deleteAll = ids.map(id => fetch(url + id, { method: 'DELETE' }))

Promise.all(deleteAll).then(result => console.log(result))

консоль:

DELETE /cart/100 200 5.150 ms - 2
DELETE /cart/101 200 4.082 ms - 2
  ./src/api/db.json has changed, reloading...

  Loading ./src/api/db.json
  ./src/api/db.json has changed, reloading...
  Done

Cannot bind to the port 3000. Please specify another port number either through --port argument or through the json-server.json configuration file

Элементы успешно удалены, но сервер падает. Я также пытался изменить порт, но это не помогло.

Не уверен, что с моим кодом что-то не так или это ошибка.

...