const apiDocConfig = {
path: 'http://localhost:3000/api/projects/1/endpoints',
}
export async function fetchDataFunc ({ docId }) {
const response = await fetch(
`${apiDocConfig.path}/${docId}`,
)
const data = await response.json()
const { requestBody, method, path } = data || {}
const { content, description } = requestBody || {}
const { properties } = content?.['application/json']?.schema || {}
return {
content: [
{
type: 'text',
text: `API name: ${docId}`
},
{
type: 'text',
text: `API description: ${description}`
},
{
type: 'text',
text: `API URL: ${path}`
},
{
type: 'text',
text: `API method: ${method}`
},
{
type: 'text',
text: `API request parameters: ${JSON.stringify(properties)}`
}
]
}
}