mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-01 05:04:15 +02:00
Template response plugin
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { YaakContext } from '@yaakapp/api';
|
||||
import jp from 'jsonpath';
|
||||
import { Context } from '@yaakapp/api';
|
||||
import { JSONPath } from 'jsonpath-plus';
|
||||
|
||||
export function pluginHookResponseFilter(_ctx: YaakContext, args: { filter: string; body: string }) {
|
||||
export function pluginHookResponseFilter(_ctx: Context, args: { filter: string; body: string }) {
|
||||
const parsed = JSON.parse(args.body);
|
||||
const filtered = jp.query(parsed, args.filter);
|
||||
const filtered = JSONPath({ path: args.filter, json: parsed });
|
||||
return JSON.stringify(filtered, null, 2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user