Day 57: Sprint (Async & Promise)
1. TIL (Today I Learned)
I had a big drop in self confidence and lost my pace on catching up on to the bootcamp, however, during the past week's pair programming I met this great 2 guys who helped me to understand what callback and promises are and also gave me a motivation to work on my dream to start up a busines in Southeast Asia. However today I am here to get my blog going on again and share some things I learned today.
The sprint was about learning how to use fs.module in node.js. I know this sounds really something new but it is basically a module that allows you to read a file using JS codes. The sprint required me to construct a code that reads a file and then use callbacks, promises, and async/await to return the merged data.
The first challenge was to come up with a function that reads a given file and returns the information in the given file.
const fs = require("fs"); // this lets you use the fs.module it is something like the import command in React.
const getDataFromFile = function (filePath, callback) {
fs.readFile(filePath, 'utf-8', (error, data) => { // this is how you use the fs.module inside your function. The first parameter is the location of the file you want to read on, the second is some kind of code I will have to study on, and the third is a callback function which holds a parameter of error and data.
if (error) callback(error, null);
else callback(null, data)
})
}
Next is using the promise constructor to accomplish the same thing as the above code.
const fs = require("fs");
const getDataFromFilePromise = filePath => {
return new Promise((resolve, reject) => {
fs.readFile(filePath, 'utf-8', (error, data) => {
if (error) reject(error) // When using Promise constructor instead, you don't have to throw an error when the information holds an error, we use reject as a function to throw an error.
else resolve(data) // We then use resolve when the data is given and is not an error.
})
})
};
2. 3 Things to be Thankful for
- Thank you God for allowing me to have a day of full study.
- Thank you God for reminding me that all my plans are just human-made plans and you have the strength to bring me to places.
- Thank you God for reminding me to call onto you at all times.
3. Ideas and Things to Think about
- How does most startups cover the needs of a basic income to stay motivated to work on the startup. Does everyone just simply bootstrap by receiving nothing? For now, I think that we have to invest in giving people a salary in order to keep them working.
- What are the ways we can start a bootcamp in Thailand ? Contact codestates for data or just start our own.
- What are the things codestates can do better to make a even better bootcamp.
- Is there demand on coding bootcamps in Thailand?
- What are the ways we can kickstart our business in Thailand?
ex. Train 1 group of students in a coding bootcamp and use them as workers in the Thailand bootcamp company. Then expand.
Author And Source
이 문제에 관하여(Day 57: Sprint (Async & Promise)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://velog.io/@inseoparkk/Day-57-Sprint-Async-Promise
저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
- How does most startups cover the needs of a basic income to stay motivated to work on the startup. Does everyone just simply bootstrap by receiving nothing? For now, I think that we have to invest in giving people a salary in order to keep them working.
- What are the ways we can start a bootcamp in Thailand ? Contact codestates for data or just start our own.
- What are the things codestates can do better to make a even better bootcamp.
- Is there demand on coding bootcamps in Thailand?
- What are the ways we can kickstart our business in Thailand?
ex. Train 1 group of students in a coding bootcamp and use them as workers in the Thailand bootcamp company. Then expand.
Author And Source
이 문제에 관하여(Day 57: Sprint (Async & Promise)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@inseoparkk/Day-57-Sprint-Async-Promise저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)