File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -14,21 +14,27 @@ document.addEventListener("DOMContentLoaded", function () {
1414 try {
1515 const response = await fetch ( "https://chatproxy.azurewebsites.net/api/chatproxy" , {
1616 method : "POST" ,
17- headers : {
18- "Content-Type" : "application/json"
19- } ,
17+ headers : { "Content-Type" : "application/json" } ,
2018 body : JSON . stringify ( { message : userMessage } )
2119 } ) ;
2220
21+ const text = await response . text ( ) ;
22+
2323 if ( ! response . ok ) {
24- throw new Error ( `Serverfout: ${ response . status } ` ) ;
24+ console . error ( "Foutstatus:" , response . status , text ) ;
25+ appendMessage ( "assistant" , `⚠️ Serverfout (${ response . status } ): ${ text } ` ) ;
26+ return ;
27+ }
28+
29+ if ( ! text || text . trim ( ) === "" ) {
30+ appendMessage ( "assistant" , "⚠️ Geen antwoord ontvangen van de chatbot." ) ;
31+ return ;
2532 }
2633
27- const text = await response . text ( ) ;
2834 appendMessage ( "assistant" , text ) ;
2935 } catch ( error ) {
3036 console . error ( "Fout in fetch:" , error ) ;
31- appendMessage ( "assistant" , "⚠️ Er ging iets mis bij het ophalen van het antwoord ." ) ;
37+ appendMessage ( "assistant" , "⚠️ Verbindingsfout of onbekende fout ." ) ;
3238 }
3339 } ) ;
3440
You can’t perform that action at this time.
0 commit comments