As a conequence the program stop working.
It seems that there is no way to get rid of the error message in the error.log window.
I tried three different versions of ajax Javascript:
- fetch
- app.HttpRequest
- await fetch
each one with different code logic.
I understand other developers are experiencing the same problem, for instance:
My app pretends to access Openai APIs directly from Javascript (see code below).
How to avoid the restriction of third party cookies?
Anybody in this group is experiencing the same?
Example of code below:
async function openaiStartThreadCreation(text,openaiApiKey,assistantId) {
var url = ‘https://api.openai.com/v1/threads’;
const options = {
method: ‘POST’,
headers: {
‘Authorization’: 'Bearer ’ + openaiApiKey,
‘Content-Type’: ‘application/json’,
‘OpenAI-Beta’: ‘assistants=v1’
},
body: JSON.stringify({
messages: [{ role: ‘user’, content: text }]
})
}
try {
const response = await fetch(url, options);
const data = await response.json();
if ( isEmpty(data) ) {
app.Alert(t_norisp[lang],t_err[lang]);
}
openaiRunAssistant(data.id, assistantId, openaiApiKey);
} catch(e) {
console.error('Error: ', e);
app.Alert(t_norisp[lang],t_err[lang]);
}
}