I'm an idiot! 😫 Not because I couldn't figure out how to do this... but because it took me so long to quit trying and just let Chat GPT fix it... which, of course, it did. At first I was following the Spoonacular example in the tutorial too literally and attempting to use GET when the API requires POST blah, blah, blah... the main take away is to just quit trying to hard and let GPT do it. 😋
Working Code:
const url = "https://api.nlpcloud.io/v1/gpu/chatdolphin/gs-correction";
const data = {
text: workflow.baseQuery
};
const headers = {
Authorization:
Bearer ${env.nlpCloudKey}
,
"Content-Type": "application/json"
};
try {
const response = await axios.post(url, data, { headers });
if (response.status === 200) {
workflow.grammarCorrected = response.data.correction;
} else {
console.log(response);
}
} catch (error) {
console.log(error);
}