Skip to content

Instantly share code, notes, and snippets.

@MauricioSilv
Created March 31, 2020 20:11
Show Gist options
  • Save MauricioSilv/989d45fe5746366a531b2e734339dee6 to your computer and use it in GitHub Desktop.
Save MauricioSilv/989d45fe5746366a531b2e734339dee6 to your computer and use it in GitHub Desktop.
const axios = require('axios');
class getdataController{
async index(req, res){
try {
const response = await axios.get('https://api.codenation.dev/v1/challenge/dev-ps/generate-data?token=TOKEN');
const { cifrado } = response.data;
var new_message = "";
for(const letra of cifrado){
let message = letra.charCodeAt(0);
if(message >= 97 && message <= 122){
let msg = message - response.data.numero_casas;
if(new_message < 97){
new_message += String.fromCharCode(122 - (96 - msg))
}else{
new_message += String.fromCharCode(msg);
}
}else{
new_message += String.fromCharCode(message);
}
}
console.log(new_message);
} catch (error) {
console.log(error);
}
}
}
module.exports = new getdataController();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment