Skip to content

Instantly share code, notes, and snippets.

View max8hine's full-sized avatar
🎯
Focusing

Max Ma max8hine

🎯
Focusing
View GitHub Profile
@max8hine
max8hine / middleware.js
Created March 13, 2018 22:32
[Express.js] Get raw Data from req.on when you use body-parser
/*
`app.use(bodyParser.json())`
`Content-Type=application/json`
BodyParser will parses json data correctly
And cleanup() from raw-body, a dependency of body-parser will clean-up the raw data
*/
function cleanup() {
received = bufer = null
stream.removeListener('data', onData)
@max8hine
max8hine / lesson_1.jsx
Last active October 1, 2017 09:52
Leverage New Features of React 16
/*
Leverage New Features of React 16
Lesson 1: Error Handling using Error Boundaries in React 16
*/
import React, { Component } from 'react';
import sendToErrorReporting from './sendToErrorReporting';
// Reusable ErrorBoundary component
@max8hine
max8hine / App.jsx
Last active October 1, 2017 04:13
fetch API + async/await
const { render } = window.ReactDOM;
const { Component } = window.React;
class App extends Component {
constructor() {
super();
this.state = { data: null, }
}
componentWillMount() {
this.getData();