Adrian Higuita
Adrian Higuita

Reputation: 71

How to read xml file content with vuejs Server side?

I need to read a xml file storaged in a specifice path in server side.. I am using the VueJS and I can-t use JQUERY... could you help me with some idea or advice?

Case: 1. The file will be storage in /static/label/custom-label.xml 2. I need to read this file of the server side and load the contect. 3. I will use the content loaded in a const.

Upvotes: 1

Views: 1823

Answers (1)

Peter-M
Peter-M

Reputation: 145

Not sure what backend you're using, but it's flagged as JS so I'll assume Node/Express. Correct me if I'm wrong.

Use express middleware to define your paths. If you're storing assets on your server for public consumption, store them in your /public/ folder.

app.use('/static', express.static('public'));
app.use(express.static('files'));

Use /static/ route to get static resources

http://localhost:3000/static/foobar.jpg

https://expressjs.com/en/starter/static-files.html

This SO post may help: Read remote file with node.js (http.get)

Upvotes: 1

Related Questions