Use json file only client side in meteor - json

I have a json file with information scrapped dayly from the web and as it's just a small array I decided to put it in a file in the public folder and read it client side. The array will be used as the options for a select tag.
I would like to read it only client side without pinging the server. How can I read the file in a template helper?
As I'm new to web development the file client side solution was the one I thought was best. If you believe there's a better way please state it and explain why is better. Thanks

You can use the http package to make a httprequest to the 'public' folder.
HTTP.get("yourweb/yourfile.json",{},function(error,result){
//do something with result
});
https://docs.meteor.com/api/http.html

Related

Is it possible send a specified file (input type=file)?

I need to upload a file repeatedly by browser (automatic) and refresh time ask me for confirm.
How can i to POST form with a specified file?
Sorry my english
It would be nice if you make available what you already tried, then we know where you are getting stuck.
Basically if you need to upload a file to a remote server you will need a dynamic language like PHP, Python, etc.
You can't send files to a remote server using plain HTML.
For security reasons HTML itself won't let you send files to a remote webserver via <form> automatically.
For that feature you would have to have your webserver handle the form via a special file like for example <form action="exampleFormHandler.php" method="post">.
Placed at your webserver, this form-handling file would have to provide the sending of that very file then.

How to upload an image using node.js+mysql+express?

I am new to Node.js ,with the help of this
tutorial I've learned how to write REST API using Node.js .Can anybody please help me to understand how to upload an image file using Node.js and saving it in mysql table ? I've been searching for it , but couldn't get something useful . Any help would be useful to me.
Typically files are uploaded as multipart form data from a web page. You could start there with a simple <input type="file"> on a web page.
Create an endpoint in Express, and consider a package to help parse it. One like express-formidable would be a good start. Then you will have the file from the request.
To save to mysql, I'd suggest the package knexjs. This is a nice library to programmatically write SQL queries. You'll have to define your own tables that store the image (probably as BLOBs) and you can use Knex to store the new images into your DB.
Be aware of the asynchronous flow in NodeJS. For your Express endpoints, you only want to finish the response after the DB code is done, like inside the knex call's callback (or at the final .then() of a promise chain)

Can node-red html be edite elsewhere?

I'm developing a node-red application right now that uses a html response. The html uses google maps, visual indicators and websockets. It is very hard to debug this system through node-red's little html editor. Is there a way to edit the html file through any normal editor (e.g. vs code) and then deploy the application again to see the effect ?
One solution that came to my mind was to read from an external file using the file node and return it as html, put I don't know if that works. Is there a better way ?
You can create and edit static resources (html/css files etc) however you'd like and then serve them from Node-RED.
You have two options for serving static content:
create corresponding HTTP In -> File In -> HTTP Response flows for each file you want to serve
or use the httpStatic property in your settings.js file to identify a directory whose content should be automatically served by the runtime.

Correct way of importing data from json in Ionic 2 using an interface

I'm really wondering what's the correct and best-practice way for importing data from a json file in an ionic 2 project so I can show it in a template, for example.
Some solutions I can find use interfaces, some don't. Some implement own small services, some don't. Some use http.get().map().subscribe(), some just use subscribe(). I would really like to know how to do this properly and would be glad if somebody could enlighten me.
From my view the best practice is to use a service and use http get request to get json file from your server. We did the same for getting language json file.
If you want securely get json file then you should put your json file at secure folder rather than public folder and create an api to get json file or json object from server.
Hope it will help

Angular2 updating JSON file

I have hosted a JSON file on my server locally. I am working with angular2 right now and have a JSON object that is to be used to overwrite the original one in the JSON file hosted. How do I do that? I am really new to these concepts.
cannot understand scenario clearly that what you want to achieve ?
cause if you want to change something on server meaning(JSON file)
then you need server side scripting ie. NodeJS,PHP,Java and angular 2 is only for client side so basically angular 2 has no access to change anything from server. Hope it helps or help me to clear scenario you are fighting.