+ 1
Js fetch API always returns undefined[resolved]
I am creating a chatbot on a website. In it the client side code uses fetch api to obtain reply from chatbot on a server. However it always returns undefined. Here is the server side snippet(flask python): @app.route("/rep/<input>") def rep(input): return jsonify(reply=ai_reply(input)) Here is the client side code: https://www.pythonanywhere.com/user/pbkdev/shares/d9468a10cb134611bd5f600d65180095/ What is the error please help? https://code.sololearn.com/WNDKG05Z731I/?ref=app
2 Answers
+ 5
You need to provide a full URL
'/rep/'+input will not work.
See example
https://code.sololearn.com/WUN219pVaXPX/#html
+ 1
My server log shows the request is being processed and the response is being sent back. That is a relative url and it will work for intrawebsite requests