From eec13f9c9733e88a6e95885f108281a5fac3e78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Bardaj=C3=AD=20Puig?= Date: Tue, 15 Oct 2024 11:57:04 +0200 Subject: [PATCH] Stringify and use res text --- src/stacks-rpc-api/smart-contracts/map-entry.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stacks-rpc-api/smart-contracts/map-entry.ts b/src/stacks-rpc-api/smart-contracts/map-entry.ts index dfb0344..222504f 100644 --- a/src/stacks-rpc-api/smart-contracts/map-entry.ts +++ b/src/stacks-rpc-api/smart-contracts/map-entry.ts @@ -38,7 +38,10 @@ export async function mapEntry(args: Args): Promise> { }; } init.method = "POST"; - init.body = args.mapKey.startsWith("0x") ? args.mapKey : `0x${args.mapKey}`; + init.body = JSON.stringify( + args.mapKey.startsWith("0x") ? args.mapKey : `0x${args.mapKey}`, + ); + init.headers = { ...init.headers, "Content-Type": "application/json" }; const endpoint = `${args.baseUrl}/v2/map_entry/${args.contractAddress}/${args.contractName}/${args.mapName}?${search}`; const res = await fetch(endpoint, init); @@ -47,10 +50,11 @@ export async function mapEntry(args: Args): Promise> { name: "FetchMapEntryError", message: "Failed to fetch map entry.", data: { + init, status: res.status, statusText: res.statusText, endpoint, - bodyParseResult: await safePromise(res.json()), + bodyParseResult: await safePromise(res.text()), }, }); }