Currently experimenting with various tools, I've been delving into Angular. Recently, I came across this informative Tutorial that helped me set up a basic example application successfully.
In the data.service.ts
file, I have defined a method called getUsers() :
getUsers() {
return this.http.get('https://jsonplaceholder.typicode.com/users')
}
The tutorial makes use of the jsonplaceholder API. My query is: If I develop an Angular application and make it public, will the user be able to view the API URL? Or does Typescript/Javascript run on the server-side (Node.js) while the client only sees a call to 'getUsers()' and receives JSON data without accessing the actual API URL?
On another note, if I intend to utilize my own MySQL database for storing user information, do I need to create an API for interacting with the DB, or can I establish a direct connection as shown in this JavaScript snippet:
var mysql = require('mysql')
var con = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'test',
database: 'my_schema',
});
If connecting directly to a database like this is feasible, could there be a security concern since the connection to the database would be initiated on the client side, potentially exposing sensitive information such as passwords?