const dbQuery = (query) => {
return new Promise( (resolve, reject) => {
setTimeout( ()=> { resolve(`Results for db query: ${query}`) }, 1000 * Math.floor(5*Math.random()) );
} )
}
const queries = ['Query 1', 'Query 2', 'Query 3', 'Query 4', 'Query 5'];
// Fix this snippet of code so that it prints the query results
queries.forEach( q => console.log(dbQuery(q)) );
Created
November 14, 2023 18:13
-
-
Save vvasc/34bb4cad11497628aa056a138094ff63 to your computer and use it in GitHub Desktop.
Your task is to demonstrate your skills in backend development using Express.js by integrating two external APIs and creating new endpoints with specific functionalities.
Access the provided sandbox link containing a simple Express.js server setup: Express API Sandbox. Integration Task: https://codesandbox.io/p/sandbox/simple-express-server-forked-6sjsjq?file=%2Fsrc%2Findex.js%3A21%2C30
You will integrate two external endpoints:
-
Albums API: https://jsonplaceholder.typicode.com/albums Contains: id, title
-
Photos API: https://jsonplaceholder.typicode.com/photos Contains: url, title, albumId
- Retrieve and combine data from both APIs.
- Structure the final output so that each album includes all its related photos. The structure should be intuitive and easy to navigate. Endpoint Creation:
- Develop a new endpoint within the Express.js application. This endpoint should accept an id as a request parameter. It will filter and return the album corresponding to the passed id, along with its related photos.
- Code Quality: Write clean, efficient, and well-documented code.
- Error Handling: Implement proper error handling for external API calls and data processing.
- Correctness of the integration and data merging.
- Efficiency of the solution.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment