Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new feature Stack #163

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

Niko5199
Copy link

Hola esta es mi solucion

  • Primero creo un metodo llamado "filterByStack"
  • Segundo este metodo recibe 2 parametros los cuales son: "explorers" y "stack"
  • El siguiente punto es que trabajaremos a base del filtrado, es decir filtraremos los explorers que
    cumplan con las condiciones.
  • Luego usaremos el arreglo de stacks veremos si el stack que buscamos, existe en este arreglo

` static filterByStack(explorers, stack) {
const explorersByStack = explorers.filter(
(explorer) => explorer.stacks.includes(stack) === true
);

    return explorersByStack;
}`

Luego en la clase "ExplorerController.js" agregamos la nueva funcion para pasarla a la ruta:

static getExplorersByStack(stack) { const explorers = Reader.readJsonFile("explorers.json"); return ExplorerService.filterByStack(explorers, stack); }

Aqui si nos damos cuenta solo pasamos el stack, pasamos el parametro de la ruta que deseamos filtrar

Luego en nuestro controlador va a quedar con la nueva ruta:

app.get("/v1/explorers/stack/:stack", (request, response) => { const { stack } = request.params; const stacksExplorers = ExplorerController.getExplorersByStack(stack); response.json(stacksExplorers); });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant