Skip to content

Instantly share code, notes, and snippets.

View xeusteerapat's full-sized avatar
🤔
Focusing

Teerapat Prommarak xeusteerapat

🤔
Focusing
View GitHub Profile
@xeusteerapat
xeusteerapat / register.js
Created April 10, 2020 08:05
Example submit client form to database (mongo)
const handleSubmit = async e => {
e.preventDefault();
if (password !== confirmpassword) {
console.log('Password does not match');
} else {
const newUser = {
name,
email,
password
};
@xeusteerapat
xeusteerapat / todo.js
Created March 27, 2020 04:03
simple react todo app
import React from 'react';
class App extends React.Component {
state = {
text: '',
todos: []
};
handleChange = e => {
e.preventDefault();
@xeusteerapat
xeusteerapat / esModule.js
Created March 23, 2020 06:06
Check my knowledge es2015 module
export const fruits = [
'🍇',
'🍈',
'🍉',
'🍊',
'🍋',
'🍌',
'🍍',
'🍎',
'🍏',
const fs = require('fs');
// create my own fetch function
const myFetch = path => {
return new Promise((resolve, reject) => {
let data = {
obj: fs.readFileSync(path, 'utf8'),
toJSON() {
return new Promise((resolve, reject) => {
resolve(JSON.parse(this.obj));
@xeusteerapat
xeusteerapat / app.js
Created March 9, 2020 14:28
fetch api with Promise.all
const getData = url => {
return new Promise((resolve, reject) => {
fetch(url)
.then(response => resolve(response.json()))
.catch(error => reject(error));
});
};
const promise1 = getData('https://jsonplaceholder.typicode.com/users');
const promise2 = getData('https://jsonplaceholder.typicode.com/posts');