Skip to content

Instantly share code, notes, and snippets.

View cBevilaqua's full-sized avatar

Cristiano Sarmento cBevilaqua

View GitHub Profile
async myFn(myParam) {
// do some external API call, for example
}
async myMainFn() {
const myArray = [1,2,3];
const myFunctions = [];
for (let x = 0; x < myArray.length; x += 1) {
@cBevilaqua
cBevilaqua / async_error_handling.js
Last active February 3, 2019 16:01
Async functions error handling example
const start = async () => {
const validateInput = async (val) => {
return new Promise((resolve, reject) => {
const acceptedVal = 1;
if (parseInt(val) === acceptedVal) {
resolve('OK');
} else {
reject(`The valid input is ${acceptedVal}`);
@cBevilaqua
cBevilaqua / Login.vue
Last active November 22, 2018 12:05
Vue component using ApiClient
<template>
<div class="login">
<form>
<div>
<label for="">E-mail</label>
<input type="email" v-model="user.email"/>
</div>
<div>
<label for="">Password</label>
<input type="password" v-model="user.password"/>
@cBevilaqua
cBevilaqua / api-client.js
Created November 22, 2018 11:52
API Client for Vue
import Vue from 'vue'
export default class ApiClient {
static callAPI (method, url, data) {
const options = {
method: method,
url: `${process.env.VUE_APP_API_URL}/${url}`,
headers: {
'Content-Type': 'application/json'
}
@cBevilaqua
cBevilaqua / main.js
Created November 22, 2018 11:46
importing vue-resource
import Vue from 'vue'
import App from './App.vue'
import router from './router'
// import vue-resource module
import VueResource from 'vue-resource'
Vue.config.productionTip = false
// use the vue-resource module
Vue.use(VueResource)

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream