From 4f629435576220a95f0c0fa4c05981572d144993 Mon Sep 17 00:00:00 2001 From: Calvin Chang Date: Wed, 20 Dec 2023 23:57:26 +0800 Subject: [PATCH] enhance: receive objects as params --- src/components/EvmEditors/EvmRequestEditor.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/EvmEditors/EvmRequestEditor.tsx b/src/components/EvmEditors/EvmRequestEditor.tsx index cd6b5fb..69277cc 100644 --- a/src/components/EvmEditors/EvmRequestEditor.tsx +++ b/src/components/EvmEditors/EvmRequestEditor.tsx @@ -24,6 +24,14 @@ import ParamEditor from "./ParamEditor"; const MenuGroups = [{ title: "Request", templates: RequestTemplate }]; +const parseParamsValue = ([key, value]: string[]) => { + try { + return [key, JSON.parse(value)]; + } catch (e) { + return [key, value]; + } +}; + const EvmRequestEditor = ({ setRequestObject, }: { @@ -43,7 +51,7 @@ const EvmRequestEditor = ({ useEffect(() => { setRequestObject({ method, - params: [Object.fromEntries(params)], + params: [Object.fromEntries(params.map(parseParamsValue))], }); }, [method, params, setRequestObject]);