From 8d0c301301d93a9b871988649dbcb681cb96358a Mon Sep 17 00:00:00 2001 From: ryunix Date: Mon, 18 Sep 2023 00:59:18 +0900 Subject: [PATCH] Change options to optional --- src/rest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rest.ts b/src/rest.ts index 62ed04f..0ddb993 100644 --- a/src/rest.ts +++ b/src/rest.ts @@ -21,19 +21,19 @@ export class RestAPI { async request( method: string, path: string, - options: { + options?: { body?: any; params?: any; } ): Promise { let url = this.engine_url + path; - if (options.params) { + if (options?.params) { url += "?" + new URLSearchParams(options.params).toString(); } var fetch_options: fetchOptions = { method: method, }; - if (options.body) { + if (options?.body) { fetch_options["headers"] = { "Content-Type": "application/json" }; fetch_options["body"] = JSON.stringify(options.body); }