Skip to content

Commit

Permalink
Merge pull request #79 from blocto/enhance/receive-object-as-params
Browse files Browse the repository at this point in the history
enhance: receive objects as params
  • Loading branch information
q20274982 authored Dec 27, 2023
2 parents bdb6852 + 4f62943 commit 0f924dd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/EvmEditors/EvmRequestEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}: {
Expand All @@ -43,7 +51,7 @@ const EvmRequestEditor = ({
useEffect(() => {
setRequestObject({
method,
params: [Object.fromEntries(params)],
params: [Object.fromEntries(params.map(parseParamsValue))],
});
}, [method, params, setRequestObject]);

Expand Down

0 comments on commit 0f924dd

Please sign in to comment.