mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 13:20:41 +01:00
feat: new client-side hook filter:api.options to allow plugins to modify api requests
This commit is contained in:
@@ -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, (
|
||||
|
||||
Reference in New Issue
Block a user