This is the solution for the challenge in step 5.
- Update your serializer.js file to match a valid one
- Run
docker ps -q | xargs docker stopto stop all running containers - Run
docker-compose buildto rebuild all containers - Run
docker-compose upto start all containers - Run
docker exec -ti frontend /bin/bashto open a bash terminal in the frontend container - Run the curl command below to mimic a read
curl -X POST -d "{\"role\": \"serialize\", \"cmd\": \"read\", \"sensorId\": \"1\", \"start\": 1441400000000, \"end\": 1541497000671}" http://serializer:3001/act --header "Content-Type:application/json"
Your challenge is to wire the data reader up to the front end. To do this you will need to replace the radom value generator in the frontend/api/index.js with a call to read data from the serializer service. Once you have the code completed, restart the system using docker-compose and open the front end in a browser. You should be able to see the chart populated as before.
- In index.js add a call to
seneca.client()to allow messages to be sent from the frontend to the serializer - Remove the
readRandomfunction and theivariable - Make a call to
seneca.act()in setInterval, use the hint below if you get stuck - In the
seneca.actcallback make a call tohandleRead()passing in the data object from the callback
Hint: {role: 'serialize', cmd: 'read', sensorId: sensorId, start: start, end: end}
If you have wired everything up correctly you should see data streaming to the chart in the browser:
- Run
docker ps -q | xargs docker stopto stop all running containers - Run
docker-compose buildto rebuild all containers - Run
docker-compose upto start all containers - Get your ip address with
docker-machine ip - Point your browser to http://localhost:3000
