Issue
let me start with describing what I want to do. I'd like to make an app where the user enters data, which then gets save in a database (works fine so far).
At a certain point the user should be able to do an "export data". On the node.js backend there are xml files which serve as templates. I'd like to populate the data from several tables into these xml templates and let the user download the file.
As I am still new to angular and node.js. I stuggle to find the correct architecture for this case:
I can easily fetch the data needed from the db to angular and provide a download from there, but I am struggling to get the templates in the mix.
It felt cleaner to pass the ids to the backend and do the file creation there, so I am currently in this approach. I can also reach the templates easily. But here I am missing the angular comfort (or maybe just knowledge). I.e. I am struggling with getting the db results (hint: async, await, promises etc).
So my question is - what is the "correct" way to build the app. Where should the templates get filled. node.js or angular?
I'd like to do it right and also save some time perusing the wrong way. Thank you.
Solution
so I still don't know what the "correct" way is but creating the file in Node.js backend worked for me.
I passed the IDs with
return this.http.get(${environment.serverUrl}/createxml, {
params: { id: basicdataIDs.join(',') },
responseType: 'blob'
});
and worked my way from there.
Answered By - Daniel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.