I am building on sample 16 from Github/Webchat to build a webpage with a webchat interface.
The react app consists off different .js files to build the website( Webchat.js, Instuctor.js, App.js, Index.js) and I can't provide file Inspector.js
with the data I gathered in file Webchat.js
.
I can't find the right code to read the value of a variable from file Webchat.js
in file Inspector.js
.
I want to build a Webpage where I have on the left side a Chatbot (BotFrameWork) running, and next to it a table running which shows data that has been collected by the chatbot.
I tried answers from
how to get a variable from a file to another file in node.js
but doesn't work.
I tried to get the state of Webchat but gives only undefined
.
Example: (webchat.js) I fetched data from the bot (like [link]How to create a side window or iframe that shows data that was gathered by a Web-Chat in one web page?) and saved it in a state variable 'test'.
(instructor.js) I want to show that data e.g. in a label that is getting updated when new data comes in. How do I get access now to the value of 'test' that is created in another file?
What doesnt work: in instuctor.js:
var test2 = require ('./webchat'); Console.log(test2.state.test) //this is how I imagine it to work --> undefined with require I only get an object that has a 'name' variable 'Webchat' and which i can get out with: console.log(test2.default.name);