I'm totally new to Angular JS and Node JS. I have several JSON files (Language translations) in server side. According to client request I need to retrieve data of JSON file. If user request french language , I need to retrieve data of that particular JSON file. This is what I tried based on search. It's not working. Can someone help me with proper method?
function getTranslations (
request /* : Request<null, {
nextToken?: string
}, {}> */,
response /* : Object */
) {
request.headers = request.headers || {}
return authentication.authenticate(request.headers.authorization)
.then((tokenPayload) => authorisation.authorise(tokenPayload.username, permissions.TRANSLATE))
.then((authorised) => {
if (!authorised) {
return Promise.reject(boom.forbidden('Message'))
}
const options = {
url: 'files/translations/',
method: 'GET',
headers: {
'Accept': 'application/json',
'Accept-Charset': 'utf-8',
}
};
app.get("/:getValue", function(req, res) {
request(options, function(err, response, body) {
var json = JSON.parse(body);
console.log(json);
res.json(request.json)
});
});
app.listen(3000, function() {
console.log("My API is running...");
});
})
}