mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 01:21:13 +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';
|
'use strict';
|
||||||
|
|
||||||
define('api', () => {
|
define('api', ['hooks'], (hooks) => {
|
||||||
const api = {};
|
const api = {};
|
||||||
const baseUrl = config.relative_path + '/api/v3';
|
const baseUrl = config.relative_path + '/api/v3';
|
||||||
|
|
||||||
@@ -9,7 +9,10 @@ define('api', () => {
|
|||||||
config.relative_path + options.url :
|
config.relative_path + options.url :
|
||||||
baseUrl + 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)
|
$.ajax(options)
|
||||||
.done((res) => {
|
.done((res) => {
|
||||||
cb(null, (
|
cb(null, (
|
||||||
|
|||||||
Reference in New Issue
Block a user