Skip to content

Instantly share code, notes, and snippets.

@rage-engage
rage-engage / promiseFun.ts
Last active October 25, 2020 15:08
Messing around with promises.
const somePromise = () => Promise.reject(new Error('My promise error'));
const executingFunction = async() => {
try {
const arr = [1,2,3];
for(const a of arr) {
console.log('Current loop:', a);
const ans = await somePromise();
console.log('Loop', a, ans);
}
@rage-engage
rage-engage / async-await-json.js
Created June 2, 2020 07:38
When using async await with fetch, this is how response as well as it's data
const doRequest = async (file) => {
const url = 'http://localhost:8080/upload';
// Add file to form data
const formData = new FormData();
formData.append('file', file);
const postData = {
method: 'PUT',
body: formData,
@rage-engage
rage-engage / rough-structure
Last active January 27, 2020 10:27
Rough project layout structure
-- components
-- Button
-- index.vue
-- index.stories.js
-- index.test.js
-- Input
-- index.vue
-- index.stories.js
-- index.test.js
-- modals

Keybase proof

I hereby claim:

  • I am rage-engage on github.
  • I am rageengage (https://keybase.io/rageengage) on keybase.
  • I have a public key ASC_hNbynuOxET-NMoHEIwWdiVMacxHqcz1XCQOR6J5W2Qo

To claim this, I am signing this object: