{"record":{"id":"a9648fc68eb2fec4","repo":"dotnet/aspnetcore","slug":"no-method-defined","errorCode":null,"errorMessage":"No method defined.","messagePattern":"No method defined\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts","lineNumber":66,"sourceCode":"            // @ts-ignore: TS doesn't know about these names\n            const requireFunc = typeof __webpack_require__ === \"function\" ? __non_webpack_require__ : require;\n\n            // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide\n            this._abortControllerType = requireFunc(\"abort-controller\");\n        } else {\n            this._abortControllerType = AbortController;\n        }\n    }\n\n    /** @inheritDoc */\n    public async send(request: HttpRequest): Promise<HttpResponse> {\n        // Check that abort was not signaled before calling send\n        if (request.abortSignal && request.abortSignal.aborted) {\n            throw new AbortError();\n        }\n\n        if (!request.method) {\n            throw new Error(\"No method defined.\");\n        }\n        if (!request.url) {\n            throw new Error(\"No url defined.\");\n        }\n\n        const abortController = new this._abortControllerType();\n\n        let error: any;\n        // Hook our abortSignal into the abort controller\n        if (request.abortSignal) {\n            request.abortSignal.onabort = () => {\n                abortController.abort();\n                error = new AbortError();\n            };\n        }\n\n        // If a timeout has been passed in, setup a timeout to call abort\n        // Type needs to be any to fit window.setTimeout and NodeJS.setTimeout","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts#L48-L84","documentation":"Thrown by FetchHttpClient.send() when request.method is falsy (undefined/empty). Before issuing the fetch, the client requires an explicit HTTP verb. This is also checked in DefaultHttpClient.send (which rejects with the same message), so it surfaces from either entry point. It indicates the HttpRequest was built without setting a method.","triggerScenarios":"Calling httpClient.send({ url: 'https://x' }) with no method; passing an HttpRequest whose method is an empty string; a helper that spreads options but forgets method.","commonSituations":"Direct use of HttpClient.send without going through get/post helpers (which set the method); a custom HttpClient wrapper that drops the method field; malformed request building.","solutions":["Use the HttpClient.get/post/delete helpers which set the method automatically instead of calling send directly.","If calling send directly, always set request.method to a valid HTTP verb.","Validate the request object before sending: assert request.method.","Add a TypeScript check by typing the argument as HttpRequest and ensuring method is provided."],"exampleFix":"// before\nawait httpClient.send({ url: 'https://example.com' });\n\n// after\nawait httpClient.get('https://example.com');\n// or\nawait httpClient.send({ method: 'GET', url: 'https://example.com' });","handlingStrategy":"validation","validationCode":"function assertRequest(req: { method?: string; url?: string }) {\n  if (!req.method) throw new Error('HttpRequest.method is required');\n  if (!req.url) throw new Error('HttpRequest.url is required');\n}\nassertRequest(request);\nawait httpClient.send(request);","typeGuard":"function hasMethod(req: { method?: string }): req is { method: string } {\n  return typeof req.method === 'string' && req.method.length > 0;\n}","tryCatchPattern":"try {\n  await httpClient.send(request);\n} catch (e) {\n  if (e.message === 'No method defined.') {\n    throw new Error('Build the HttpRequest with an HTTP method (use httpClient.get/post helpers)');\n  }\n  throw e;\n}","preventionTips":["Prefer httpClient.get(url)/.post(url, options) which set the method automatically.","When calling send directly, validate method presence first.","Type the request argument as a strict interface to catch missing fields at compile time."],"tags":["http-client","validation","fetch","request-building"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}