adding quotes in text response

This commit is contained in:
Pooja Belaramani
2024-12-27 11:12:46 +05:30
parent 582e8e5eac
commit 9a2d8bfff3
2 changed files with 6 additions and 4 deletions

View File

@@ -27,14 +27,13 @@ const formatResponse = (data, mode, filter) => {
let isValidJSON = false;
try {
isValidJSON =
typeof JSON.parse(JSON.stringify(data)) === 'object' || typeof JSON.parse(JSON.stringify(data)) === 'string';
isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object'
} catch (error) {
console.log('Error parsing JSON: ', error.message);
}
if (!isValidJSON && typeof data === 'string') {
return data;
return JSON.stringify(data);
}
if (filter) {