# extendify/3.1.6/src/Agent/workflows/extermal/tools/search-wp-docs.js

Extendify, version 3.1.6. 22 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.6/code/src/Agent/workflows/extermal/tools/search-wp-docs.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.6/raw/src/Agent/workflows/extermal/tools/search-wp-docs.js
- Modified: 2025-09-09T15:55:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.6/code/src/Agent/workflows/extermal/tools/search-wp-docs.js#L10-L20`.

```javascript
import { KB_HOST } from '@constants';

export default async ({ query }) => {
	const fallback = { documentation: 'No relevant documentation found' };
	const urlParams = new URLSearchParams({ search: query });
	const r = await fetch(`${KB_HOST}/api/posts?${urlParams.toString()}`, {
		method: 'POST',
		headers: { 'Content-Type': 'application/json' },
	}).catch(() => ({ ok: false }));
	if (!r.ok) return fallback;

	const articles = await r.json();
	if (!articles?.[0]?.slug) return fallback;
	const r2 = await fetch(`${KB_HOST}/api/posts/${articles?.[0]?.slug}`, {
		method: 'GET',
		headers: { 'Content-Type': 'application/json' },
	}).catch(() => ({ ok: false }));
	if (!r2.ok) return fallback;
	const article = await r2.json();
	return article?.content ? { documentation: article.content } : fallback;
};

```
