Hi all, my flow parses textual data using a template and GET method, however I am unable to post the result programmatically as a JSON.
I want it to be generic and simple, without using scope.send
or the 'form' method - and still be able to receive the results as msg.payload
with the http request
node. What am I missing? Thanks!
Flow:
[{"id":"a55f8f0f93e84992","type":"tab","label":"POST","disabled":false,"info":"","env":[]},{"id":"66b62d27f7d3b699","type":"http in","z":"a55f8f0f93e84992","name":"","url":"/dwvparser1","method":"get","upload":false,"swaggerDoc":"","x":120,"y":140,"wires":[["f1320111617c92f0"]]},{"id":"f1320111617c92f0","type":"template","z":"a55f8f0f93e84992","name":"DWV Parser","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<script type=\"text/javascript\" src=\"https://github.com/ivmartel/dwv/releases/download/v0.30.4/dwv-0.30.4.min.js\"></script>\n\n<div id=\"tags\"></div>\n\n<script type=\"text/javascript\">\n\n var url = 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm';\n\n var onloadtest = function(event) {\n // setup the dicom parser\n var dicomParser = new dwv.dicom.DicomParser();\n // parse the buffer\n dicomParser.parse(event.target.response);\n\n // div to display text\n var div = document.getElementById('tags');\n\n // get the raw dicom tags\n var rawTags = dicomParser.getRawDicomElements();\n // display the modality\n div.appendChild(document.createTextNode(\n\n '|Modality: ' + rawTags.x00080060.value[0] +\n '|Study Description: ' + rawTags.x00081030.value[0] +\n '|Series Description: ' + rawTags.x0008103E.value[0] +\n '|Patient ID: ' + rawTags.x00100020.value[0] +\n '|Patient Name: ' + rawTags.x00100010.value[0] +\n '|Gender: ' + rawTags.x00100040.value[0]\n ));\n\n // break line\n div.appendChild(document.createElement('br'));\n\n // get the wrapped dicom tags\n var tags = dicomParser.getDicomElements();\n // display the modality\n div.appendChild(document.createTextNode(\n 'Modality (bis): ' + tags.getFromName('Modality')\n ));\n };\n\n var request = new XMLHttpRequest();\n request.open('GET', url);\n request.responseType = 'arraybuffer';\n request.onload = onloadtest;\n request.send();\n \n // scope.send({payload: request.send() }); \n\n</script>","output":"str","x":310,"y":140,"wires":[["fd496ef1564d0ccc"]]},{"id":"fd496ef1564d0ccc","type":"http response","z":"a55f8f0f93e84992","name":"","statusCode":"","headers":{},"x":470,"y":140,"wires":[]},{"id":"f5c3a58572e4bf4c","type":"comment","z":"a55f8f0f93e84992","name":"scope.send?","info":"","x":310,"y":100,"wires":[]},{"id":"dcc6e4cff18cc687","type":"http request","z":"a55f8f0f93e84992","name":"POST request","method":"POST","ret":"obj","paytoqs":"ignore","url":"http://localhost:1880/dwvparser1","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"credentials":{},"x":260,"y":260,"wires":[["ddb924d633c036e2"]]},{"id":"ddb924d633c036e2","type":"debug","z":"a55f8f0f93e84992","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":260,"wires":[]},{"id":"8e589c2a4ea9ec1e","type":"inject","z":"a55f8f0f93e84992","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":110,"y":260,"wires":[["dcc6e4cff18cc687"]]},{"id":"4a95acbc48f11200","type":"comment","z":"a55f8f0f93e84992","name":"Send HTTP POST request","info":"","x":150,"y":200,"wires":[]}]