File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -11,19 +11,25 @@ form.addEventListener("submit", async (e) => {
1111 input . value = "" ;
1212
1313 try {
14+ console . log ( "Verzend dit naar chatproxy:" , message ) ;
15+
1416 const response = await fetch ( "https://chatproxy.azurewebsites.net/api/chatproxy" , {
1517 method : "POST" ,
1618 headers : { "Content-Type" : "application/json" } ,
1719 body : JSON . stringify ( { message } )
1820 } ) ;
1921
20- // LET OP: geen .json() gebruiken, want backend stuurt platte tekst terug
2122 const text = await response . text ( ) ;
22- appendMessage ( "Agent" , text ) ;
23+ console . log ( "Ontvangen van proxy:" , text ) ;
24+
25+ if ( ! response . ok ) {
26+ throw new Error ( `Serverfout: ${ response . status } ` ) ;
27+ }
2328
29+ appendMessage ( "Agent" , text ) ;
2430 } catch ( err ) {
25- appendMessage ( "Agent" , "Er ging iets mis." ) ;
26- console . error ( err ) ;
31+ appendMessage ( "Agent" , "Er ging iets mis bij het ophalen van het zorgdocument ." ) ;
32+ console . error ( "Fout in fetch:" , err ) ;
2733 }
2834} ) ;
2935
@@ -33,4 +39,3 @@ function appendMessage(sender, text) {
3339 chat . appendChild ( msg ) ;
3440 chat . scrollTop = chat . scrollHeight ;
3541}
36-
You can’t perform that action at this time.
0 commit comments