$ npm install -g create-react-app
$ create-react-app my-app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
class HttpService { | |
constructor() { | |
const token = window.localStorage.getItem("token"); | |
const service = axios.create({ | |
baseURL: process.env.REACT_APP_API_URL, | |
headers: token | |
? { | |
Authorization: `Bearer ${token}`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
.tree { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const convertTextToLatin = (str) => { | |
if (!str) return ''; | |
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/gi, 'a'); | |
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/gi, 'e'); | |
str = str.replace(/ì|í|ị|ỉ|ĩ/gi, 'i'); | |
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/gi, 'o'); | |
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/gi, 'u'); | |
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/gi, 'y'); | |
str = str.replace(/đ/gi, 'd'); | |
// Some system encode vietnamese combining accent as individual utf-8 characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2020-07-22T09:37:59.331Z","extensionVersion":"v3.4.3"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "ES6", | |
"baseUrl": "." | |
}, | |
"exclude": ["node_modules", "**/node_modules/*"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-console */ | |
const express = require('express') | |
const next = require('next') | |
const devProxy = { | |
'/api': { | |
target: 'https://swapi.co/api/', | |
pathRewrite: { '^/api': '/' }, | |
changeOrigin: true, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Install extend enable CORS in web browser (simple, fast but situation) | |
// 2. Using middleware plug-in in server | |
// https://expressjs.com/en/resources/middleware/cors.html | |
var express = require('express') | |
var cors = require('cors') | |
var app = express() | |
app.use(cors()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// without Optional Chaining | |
function sayHi(user) { | |
let name = (user && user.name && user.name.toUpperCase()) || "Unknown"; | |
console.log(`Hi Mr. ${name}`); | |
} | |
sayHi({}); // Hi Mr. Unknown | |
sayHi(); // Hi Mr. Unknown | |
// with Optional Chaining | |
function sayHi(user) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function split(input, len) { | |
return input.match(new RegExp('.{1,' + len + '}(?=(.{' + len + '})+(?!.))|.{1,' + len + '}$', 'g')) | |
} | |
console.log(split('11010101101', 4)) // ['110', '1010', '1101'] | |
console.log(split('ab22883b0ada0', 2)) // ['a', 'b2', '28', '83', 'b0', 'ad', 'a0'] |
NewerOlder