Skip to content

Instantly share code, notes, and snippets.

View sadick254's full-sized avatar
🎯
Focusing

Sadick sadick254

🎯
Focusing
View GitHub Profile
export async function addVehicle(userId, vehicle) {
return api.addVehicle(userId, vehicle, axios).then(data => {
if (!data.errors) {
store.dispatch({
type: types.ADD_VEHICLE,
vehicle: data.data.addVehicle
});
return data;
}
return Promise.reject(data.errors);
<?php
class User {
private $name;
private $age;
public function setName(string $name) {
$this->name = $name;
}
public function setAge($age):void
if (expresion) {
return true;
} else {
return false;
}
// which can be refactored to
return expresion;
function validateEmail(email) {
// validate and return true or false
}
function isEmailValid(email) {
// validate and return true or false
}
function emailIsValid(email) {
// validate and return true or false
<?php
class WidgetList {
public int numberOfWidgets () {...}
}
/***********************************************************
* Some fancy comments here *
* *
***********************************************************/
export default {
name: 'some-component',
data () {
return {
name: 'sadick'
}
},
methods: {
getUsername () {
this.$store.dispatch('getUsernameFromAPI')
//get all shops
const shops = await this.$store.dispatch('get', {
url: '/shops',
params: {
type: 'all'
},
type: 'GET_SHOPS_SUCCESS'
})
// use your response if you need to
export const get = ({commit}, {url = '', params = {}, type = '', canCommit = true}) => {
axios.get(url, {
params
}).then(resp => {
if (canCommit) {
commit(type, resp.data)
}
return resp.data
})
}
export const get = ({commit}, {url = '', params = {}}) => {
axios.get(url, {
params
}).then(resp => {
return resp.data
})
}