MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / callApi

Function callApi

apps/web/server/routers/threads/index.test.ts:54–85  ·  view source on GitHub ↗
({
    url,
    method,
    body,
    token,
  }: {
    url: string;
    method: string;
    body?: any;
    token?: string;
  })

Source from the content-addressed store, hash-verified

52 });
53
54 async function callApi({
55 url,
56 method,
57 body,
58 token,
59 }: {
60 url: string;
61 method: string;
62 body?: any;
63 token?: string;
64 }) {
65 return new Promise(async (res, rej) => {
66 await testApiHandler({
67 handler: handler as any,
68 url: url,
69 test: async ({ fetch }) => {
70 try {
71 const response = await fetch({
72 method: method,
73 ...attachHeaders({ token: token }),
74 ...(body && {
75 body: JSON.stringify(body),
76 }),
77 });
78 res(response.status);
79 } catch (error) {
80 rej(error);
81 }
82 },
83 });
84 });
85 }
86
87 describe(`unauthenticated user`, () => {
88 describe('public community', () => {

Callers 1

index.test.tsFile · 0.70

Calls 1

attachHeadersFunction · 0.90

Tested by

no test coverage detected