feat: make api only return json (#42320)

* fix(api): return json for delete + reset-progress

* refactor(api): make .json calls explicit

These .send() calls had objects as arguments. Using .json() makes it
explicit without changing behaviour.

* fix: return json or redirectWithFlash

We should never be getting requests for plain text, but if we do they
should be redirected back to the client.

* fix: prioritize JSON responses

If accepted, respond with JSON.  If not, it's probably a bad request.
This commit is contained in:
Oliver Eyton-Williams
2021-06-05 14:20:40 +02:00
committed by GitHub
parent 989347387f
commit 7b65909522
6 changed files with 20 additions and 29 deletions

View File

@@ -193,7 +193,7 @@ module.exports = function (app) {
pulls === parseInt(pulls, 10) && issues
? Object.keys(JSON.parse(issues)).length - pulls
: "Can't connect to GitHub";
return res.send({
return res.json({
issues: issues,
pulls: pulls
});