When making a DELETE request, it throws an error:
OPTIONS http: // localhost: 30117 / api / Goods 405 (Method Not Allowed)
Fetch API cannot load http: // localhost: 30117 / api / Goods . It doesn’t give access to the requested resource. Origin ' http: // localhost: 8070 ' is therefore not allowed access. The response had HTTP status code 405.
Error: TypeError: Failed to fetch
CORS is enabled on the Web Api server. On the client, I use the request module to send a request :
function _delete(tableName, id) { return new Promise(function(resolve, reject) { request({ method: "DELETE", url: `${_serverAddress}/${tableName}`, headers: { "Accept": "application/json" } }, function(error, response, body) { if (error) { reject(error); } else { resolve(body); } }) }); } GET requests work fine.
url: ${_serverAddress}/${tableName}, forgot to specify the id parameter here - user190794