Trying to convert the output of the script below into a Map<string,string>, but encountering an error that says "java.lang.String cannot be cast to java.util.Map". How can I successfully cast it as a map?
final JavascriptExecutor js = (JavascriptExecutor) driver;
Map<String,String> str = new HashMap<>();
str = (Map<String, String>) js.executeAsyncScript("var myHeaders = new Headers();\n" +
"myHeaders.append('client-id', 'LPDP');\n"
"let inputEntities = new Map();\n" +
"inputEntities.set(\"Commons$customerId\", \"\\\"A2ZLDCQRXMMNLG\\\"\")\n" +
"inputEntities.set(\"Commons$marketPlaceId\", \"\\\"A2XZLSVIQ0F4JT\\\" +
"let entitiesToBeResolved = [\"Rewards$APPA$GetAllPromotions$applicablePromotionDetailList\"]\n" +
"\n" +
"const executeInput = {\n" +
"\"inputEntities\": Object.fromEntries(inputEntities),\n" +
"\"entitiesToBeResolved\": entitiesToBeResolved,\n" +
"};\n" +
"var obj \n" +
"\n" +
"fetch(\"url", {\n" +
" method: 'POST',\n" +
" headers: myHeaders,\n" +
" body: JSON.stringify(executeInput),\n" +
"})\n" +
" .then(response => response.text())\n" +
" .then(arguments[0])\n" +
" .then(result => obj = result);\n" +
"\n" +
" return obj;");