Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions labs/lab-axios-functional-programming/starter-code/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let service = axios.create({
baseURL: "https://raw.githubusercontent.com/mc100s/module-3-react/labs/lab-axios-functional-programming/"
baseURL: "https://raw.githubusercontent.com/mc100s/training-labs-react/master/src/lab-axios-functional-programming"
})

function displayDataInTheConsole(page) {
Expand All @@ -12,46 +12,50 @@ function displayDataInTheConsole(page) {
function getTotalResults(page) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 1
// Update that function so it only displays the value of "total_results" (18966)
return response.data // You should write it "response.data.something"
// "total_results" (18966)
return response.data.total_results // You should write it "response.data.something"
})
// .then( result => {
// document.getElementById("getTotalResults").innerHTML = JSON.stringify(result, null, 2)
// });
}

function getFirstResultName(page) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 2
// Update that function so it only displays the name of the first actor
return response.data
return response.data.results[0].name
})
}

function getNames(page) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 3
return response.data.results.map( actor => actor.name);
})
}

function getIdsAndNames(page) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 4
return response.data.results.map( actor => `#${actor.id} ${actor.name}`);
})
}

function getSortedNames(page) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 5
return response.data.results.map( actor => actor.name).sort();
})
}

function getNamesFiltered(page, searchTerm) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 6
return response.data.results.map( actor => actor.name).filter(name => name.toUpperCase().includes(searchTerm.toUpperCase()) );
})
}

Expand All @@ -60,5 +64,17 @@ function getActorNamesWithTheirKnownForMovies(page) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 7

return response.data.results
.map( actor =>
`${actor.name} (${actor.known_for.map( movie => movie.title )})`
);
})
}

function getKnownForMovies(page) {
return service.get(`page-${page}.json`)
.then( response => {
return response.data.results.map( actor => `${actor.known_for.map( movie => movie.title )}` ).sort();
})
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// You can change that value, from 1 to 3
let page = 1
let page = 2

// You shouldn't modidify the next lines

Expand Down Expand Up @@ -32,3 +32,6 @@ getNamesFiltered(page, "m")

getActorNamesWithTheirKnownForMovies(page)
.then(updateTheDom("getActorNamesWithTheirKnownForMovies"))

getKnownForMovies(page)
.then(updateTheDom("getKnownForMovies"))
4 changes: 4 additions & 0 deletions labs/lab-axios-functional-programming/starter-code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ <h2>Names of actors, that has "m" in their name</h2>

<h2>Names of actors, with their "know_for" movies</h2>
<pre id="getActorNamesWithTheirKnownForMovies"></pre>

<h2>Names of "know_for" movies</h2>
<pre id="getKnownForMovies"></pre>


<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
<script src="api.js"></script>
Expand Down
21 changes: 21 additions & 0 deletions labs/lab-react-bulma-components/starter-code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
Loading