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

BER - Aparna Pattathil #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 41 additions & 5 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/module-3-react/master/labs/lab-axios-functional-programming/"
})

function displayDataInTheConsole(page) {
Expand All @@ -14,7 +14,7 @@ function getTotalResults(page) {
.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"
return response.data.total_results // You should write it "response.data.something"
})
}

Expand All @@ -23,42 +23,78 @@ function getFirstResultName(page) {
.then(response => {
// TODO: Iteration 2
// Update that function so it only displays the name of the first actor
return response.data
console.log(response.data.results);
return response.data.results[0].name
})
}

function getNames(page) {
return service.get(`page-${page}.json`)
.then(response => {
let namesOfActors = [];
response.data.results.map(function(i) {
// console.log(i.name);
namesOfActors.push(i.name)
} )
return namesOfActors;
// TODO: Iteration 3
})
}

function getIdsAndNames(page) {
return service.get(`page-${page}.json`)
.then(response => {
let namesAndIdOfActors = [];
response.data.results.map(function(i) {
// console.log(i.name);
namesAndIdOfActors.push(i.id + ' ' + i.name)
} )
return namesAndIdOfActors;
// TODO: Iteration 4
})
}

function getSortedNames(page) {
return service.get(`page-${page}.json`)
.then(response => {
let namesOfActors = [];
response.data.results.map(function(i) {
// console.log(i.name);
namesOfActors.push(i.name)
} )
return namesOfActors.sort();
});
// TODO: Iteration 5
})

}

function getNamesFiltered(page, searchTerm) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 6
let namesOfActors = [];
response.data.results.map(function(i) {
if (i.name.toLowerCase().includes(searchTerm.toLowerCase())) {
namesOfActors.push(i.name)
}
} )
return namesOfActors;
})
}


function getActorNamesWithTheirKnownForMovies(page) {
return service.get(`page-${page}.json`)
.then(response => {
// TODO: Iteration 7
// console.log(response.data.results);
// // TODO: Iteration 7
// return response.data.results


// .map(i =>{
// i.known_for


// })
})
}
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*