Replies: 1 comment
-
🤖 It seems like you're trying to parse a stringified JSON object back into JSON. However, the issue here is that Here's how you can fix it: In your backend code, you don't need to stringify and parse the result. You can directly send the result as JSON. Modify your backend code like this: result = await chain.call({
query: message,
});
console.log(result);
return res.status(200).json(result); In your frontend code, you're trying to parse the response from the server. However, since the response is already in JSON format, you don't need to parse it. You can directly access the try {
const searchRes = await response.json();
console.log(searchRes.text);
} catch (err) {
console.log("Error parsing", err);
}
const botText = searchRes.text;
console.log(botText); This should solve your issue. If you still face any problems, please provide more details about the error you're encountering. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The answer from the AI goes here:
^^ How can I fix this answer to be properly accepted as a JSON?
Full backend code here:
Full frontend code here:
Beta Was this translation helpful? Give feedback.
All reactions