MCPcopy Create free account
hub / github.com/simstudioai/sim / unwrapOdata

Function unwrapOdata

apps/sim/app/api/tools/sap_s4hana/proxy/route.ts:300–316  ·  view source on GitHub ↗
(body: unknown)

Source from the content-addressed store, hash-verified

298}
299
300function unwrapOdata(body: unknown): unknown {
301 if (!body || typeof body !== 'object') return body
302 const root = (body as { d?: unknown }).d
303 if (root === undefined) return body
304 if (root && typeof root === 'object' && 'results' in (root as Record<string, unknown>)) {
305 const rootObj = root as { results: unknown; __count?: string; __next?: string }
306 if (rootObj.__count !== undefined || rootObj.__next !== undefined) {
307 return {
308 results: rootObj.results,
309 ...(rootObj.__count !== undefined && { __count: rootObj.__count }),
310 ...(rootObj.__next !== undefined && { __next: rootObj.__next }),
311 }
312 }
313 return rootObj.results
314 }
315 return root
316}
317
318export const POST = withRouteHandler(async (request: NextRequest) => {
319 const requestId = generateRequestId()

Callers 1

route.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected