Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gndx committed May 27, 2020
0 parents commit aece2aa
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Comunidad Platzi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## DESCRIPTION

Nombre:
Usuario Platzi:

## Ciudad
- [ ] Ciudad de México
- [ ] Bogotá

# Retos:
- [ ] Primer problema
- [ ] Segundo problema
- [ ] Tercer problema
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# escuelajs-reto-03
Reto 3 Septiembre 14: Curso de Fundamentos de JavaScript

# Instalación

```
npm install
```
# Ejecución

```
npm run start
```

### Primer problema
La aplicación tiene errores que no permiten ejecutarla, lee detenidamente el código y determina dónde se encuentran al ejecutarlo en la consola.

### Segundo Problema
Una vez que tu aplicación ya esté funcionando convierte el código a ECMAScript 6 (ES6)
* Arrow Functions
* Template Strings

### Tercer Problema
Transforma el código escrito en ECMAScript6(ES6) para que funcione con promesas y así evitar el Callback Hell del final.

# Contributing
If someone wants to add or improve something, I invite you to collaborate directly in this repository: [escuelajs-reto-03](https://github.com/platzi/escuelajs-reto-03/)

# License
escuelajs-reto-03 is released under the [MIT License](https://opensource.org/licenses/MIT).
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "escuelajs-reto-03",
"version": "1.0.0",
"description": "Reto 3 Septiembre 14: Curso de Fundamentos de JavaScript",
"main": "index.js",
"scripts": {
"start": "node src/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/platzi/escuelajs-reto-03.git"
},
"keywords": [
"javascript",
"escuelajs",
"node"
],
"author": "Oscar Barajas <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/platzi/escuelajs-reto-03/issues"
},
"homepage": "https://github.com/platzi/escuelajs-reto-03#readme",
"dependencies": {
"xmlhttprequest": "^1.8.0"
}
}
32 changes: 32 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;

var API = 'https://rickandmortyapi.com/api/character/';
var xhttp = new XMLHttpRequest();

function fetchData(url_api, callback) {
xhttp.onreadystatechange = function (event) {
if (xhttp.readyState === '4') {
if (xhttp.status == 200)
callback(null, xhttp.responseText);
else return callback(url_api);
}
};
xhttp.open('GET', url_api, false);
xhttp.send();
};

fetchData(API, function (error1, data1) {
if (error1) return console.error('Error' + ' ' + error1);
console.log('Primer Llamado...')
fetchData(API + data1.results[0].id, function (error2, data2) {
if (error2) return console.error(error1);
console.log('Segundo Llamado...')
fetchData(data2.origin.url, function (error3, data3) {
if (error3) return console.error(error3);
console.log('Tercero Llamado...')
console.log('Personajes:' + ' ' + data1.info.count);
console.log('Primer Personaje:' + ' ' + data2.name);
console.log('Dimensión:' + ' ' + data3.dimension);
});
});
});

0 comments on commit aece2aa

Please sign in to comment.