Created
May 13, 2020 01:54
-
-
Save DesolatorMagno/0116229f853226e4d21f0935214159e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch(route,{ | |
method: 'get' | |
}).then(function(response){ | |
return response.text(); | |
}).then(function(res){ | |
console.log(res) | |
}).catch(function(err){ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Rendodea cualquiera numero a 1 o 2 decimales | |
function roundToTwo(num) { | |
return +(Math.round(num + "e+2") + "e-2"); | |
} | |
function roundToOne(num) { | |
return +(Math.round(num + "e+1") + "e-1"); | |
} | |
//Slugify a string | |
function slugify(string) { | |
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'; | |
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnooooooooprrsssssttuuuuuuuuuwxyyzzz------'; | |
const p = new RegExp(a.split('').join('|'), 'g'); | |
return string.toString() | |
.toLowerCase() | |
.replace(/\s+/g, "-") | |
.replace(p, c => b.charAt(a.indexOf(c))) | |
.replace(/&/g, '-and-') | |
.replace(/[^\w\-]+/g, '') | |
.replace(/\-\-+/g, '-') | |
.replace(/^-+/, '') | |
.replace(/-+$/, ''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment