Skip to content

Node.js based forum software built for the modern web

feat: new client-side hook `filter:api.options` to allow plugins to modify api requests

Julian Lam7d391d4789ca
diff --git a/public/src/modules/api.js b/public/src/modules/api.js
index d55f9899ba..614b799f04 100644
--- a/public/src/modules/api.js
+++ b/public/src/modules/api.js
@@ -1,6 +1,6 @@
'use strict';
-define('api', () => {
+define('api', ['hooks'], (hooks) => {
const api = {};
const baseUrl = config.relative_path + '/api/v3';
@@ -9,7 +9,10 @@ define('api', () => {
config.relative_path + options.url :
baseUrl + options.url;
- function doAjax(cb) {
+ async function doAjax(cb) {
+ // Allow options to be modified by plugins, etc.
+ ({ options } = await hooks.fire('filter:api.options', { options }));
+
$.ajax(options)
.done((res) => {
cb(null, (