How can i connect my static service my backend with mysql database please i am new here help me
this method is in index.html
type or paste code here
fetch('https://qanda-6l91.onrender.com/answers', {
method:'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({Ans_value})
})
this is also in index.html
async function Loadanswers(){
const res = await fetch('https://qanda-6l91.onrender.com/answers');
const answers = await res.json();
const ctr = document.querySelector('.container');
this one is in index.js
const express = require('express')
const app = express()
const port = 3000
const bodyParser = require('body-parser');
const db = require('./db')
app.use(bodyParser.json())
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*"); // disabled for security on local
res.header("Access-Control-Allow-Headers", "Content-Type");
next();
});
this code is in db.js
async function getConnection() {
return await typeorm.createConnection({
type: "mysql",
host: "localhost",
port: 3000,
username: "root",
password: "password",
database: "myapplication",
synchronize: false,
logging: false,
entities: [
AnswerSchema
]
});
Please help me connecting these all together in render for the front end i used static service for the backend i used webservice my database is mysql so how i can make a connection between these services.