Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Im new to javascript and want to start writing code as clean(correct) as possible. I use C# WebApi as backend and simple pure HTML + JavaScript project for frontend.
Up until now I stored configuration for my frontend in javascript files like this:
var serviceUri = 'http://localhost:666/api/service';
And just use them somewhere.
In real applications this should be outside any javascript files, at least in my opinion. Similar to how I do it with .NET stand-alone applications or WCF services. How I should store this kind of configuration for frontend application? What is best practises?
You do not need to specify the server location of the web api in javascript. If you just use var serviceUri = '/api/service'; it will take the current server location of your page.
And if you are using static files the problem that you have to change the service location both in the js and the web api will remain and cannot be get rid of without you implementing your own compile tools (which will be a pain in the ass to find the correct routing and so on).
In the enterprise solutions I've worked on we just deal with it. You could create a js file to have all the api endpoints in one place but this could easly get ugly when there are to many.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 10 months ago.
Improve this question
I am pretty new to web dev, and I wanted to create a simple UI in Javascript with the Google Maps Places API to familiarize myself with everything. My question is, would I just make direct URL requests with the user’s variables, or would I have to create something server side, and if so, what would I have to do?
It depends on your application's functionality. Generally, you could keep all everything on the client-side. If you app is a server-rendered one, meaning you would be using a JavaScript framework like React or Vue, you could use just the website state to keep track of users' variables and send out requests to the Google APIs to do the heavy work.
You could also look into tools like Firebase, also created by the folks at Google to handle storage or user authentication. There are rich docs on how to include Firebase in your web application for your framework of choice. This way you can create language-agnostic backend resources that conform to all of the security measures and scales automatically so you can focus on the users' experience.
In case you would like to offer some less-common functionality or have complete control over the backend you could write up an API of your own and have it deployed on a separate backend server.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I think it's funny to say 'using Node.js in html'
but i want to know
First, I have less base of related knowledge of this
I want to make my website with mysql data (some data in it). and i wanna bring my data to use data when I program.
I made my html and some javascript codes in it.
As far as I know, Node.js is used to connect mysql to javascript.(This is not sure. I just learned myself)
So, how can I use mysql data when I code javascript in html by using node.js??
Are there some other solutions of this?
Sorry the questions aren't clear.
You can't use Node.js in HTML.
A <script> element in an HTML document can be used to run JS, embedded in a webpage, in the JS engine that is embedded in a browser.
Node.js is a way to run JS that is not embedded in a browser.
The traditional way to use Node.js in combination with a web page is to write an HTTP server in Node.js (typically using the Express.js module) and then communicate with it from JS in the page (usually with Ajax but sometimes with WebSockets or Socket.io).
You can also generate HTML documents directly from the Node.js HTTP server instead of using a web service.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm trying to build an API for a react project and I'm unsure of how to build an API.
I have a CSV file with all the data.
I've used api-platform via PHP but every time I try to input the CSV into the tables in Sequel Pro it crashes.
I'm now thinking of using node.js.
Very confused as to which technology to use and the best approach to my problem.
Looked at many articles and tutorials that have helped build a basic RESTful API however none of them address how to add a CSV file into the tables or database.
My personal recommendation when building an RESTful API in Node.js is to use express.js. Easy to get started with and has many plugins.
Other possible frameworks that I can think of right now:
hapi.js
koa.js
For reading and writing CSV-files, take a look at this article
I think python can handle CSV files better. You can create API using Django.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Now I program all my web apps with Flask or Django. (blogs, social networks...). I need templates, db access, controllers, routing...
Now I want to do same web applications, but with javascript.
People tell me : You need NodeJs for server-side, Angular for the front, and for example firebase or mongodb. Or also you can use Express JS.
But can I just use Angular JS and Firebase for start a big web app ? Need I Node if Angular can Access/Update/Delete in my db ?
Angular is a client-side framework, so you'll have to at least have some web server to serve your static files. Other than that, if you're using Firebase, you wouldn't technically need any server-side code to handle your logic - but naturally, that depends strongly on what data your application deals with.
If what Firebase provides, doesn't cut it for your cases though, you will need a server-side, and pretty much any web application framework would do. Node.js (using Express), PHP, ASP.NET, whatever your heart desires.
And yes, Angular works perfectly well for creating big complex web applications.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am trying to understand google two programing language.
Dart --> Produce Javascript
Go --> Produce machine code
If I need to combine Client - Server model. I am wondering how the architecture works.
How does it work. Is there any example/sample.
Example : Please explain this.....
I type www.learnlang.com. I expect WEB UI is served using Dart and It is calling REST API developed in GO language.
Note : Please don't relate google app engine. I am trying to understand the model in individual servers.
Thank you.
I think you got it right! So for example you compile your dart app using dart2js to produce javascript code. Then you can serve this code through a web server (like Apache or Nginx).
This code gets downloaded by clients as Javascript. Your Javascript code may connect to a backend written in Go through HttpRequests or WebSockets.
You can exchange data through both layers with JSON, XML, whatever you want.
Go will most likely run as a process, and embed its own "listening to HttpRequests" mechanism for the API.