SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.07k stars 650 forks source link

[Bug]: Delete row or Bulk Delete with Hapi and TypeORM #1579

Open varshiludani opened 8 months ago

varshiludani commented 8 months ago

Contact Details

No response

What happened?

  1. Start a new project.
  2. Install Hapi and TypeORM as the plugin and adapter (as per the docuemention).
  3. Create a new entry.
  4. Try to delete the entry
  5. Error - 415 (Unsupported Media Type)

Bug prevalence

Always

AdminJS dependencies version

"devDependencies": { "@types/node": "^16.18.61", "ts-node": "10.9.1", "typescript": "4.5.2" }, "dependencies": { "@adminjs/hapi": "^7.0.1", "@adminjs/typeorm": "^5.0.0", "@hapi/boom": "^10.0.1", "@hapi/cookie": "^12.0.1", "@hapi/hapi": "^21.3.2", "@hapi/inert": "^7.1.0", "adminjs": "^7.3.0", "pg": "^8.11.3", "reflect-metadata": "^0.1.13", "typeorm": "^0.3.17" },

What browsers do you see the problem on?

Firefox, Chrome, Safari, Microsoft Edge

Relevant log output

AxiosError {message: 'Request failed with status code 415', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}

Relevant code that's giving you issues

No response

varshiludani commented 8 months ago

I have also tried to copy the request into Postman and I faced the same issue. A workaround in Postman was to pass id in the body as part of the Post request as form-data.

dziraf commented 8 months ago

Are there any errors appearing in the server's console besides the Axios error in the browser's console?

A workaround in Postman was to pass id in the body as part of the Post request as form-data.

The delete endpoint actually uses request params to get recordId. The bulkDelete endpoint uses ?recordIds query params. Could you try sending a Postman request with some random stuff in the body? Example: { "abc": "123" }. I wonder if 415 is thrown because the frontend sends an empty body in POST request, other frameworks respect this though 🤔