Skip to content

Instantly share code, notes, and snippets.

View Godofbrowser's full-sized avatar
🔥
Setting browsers on fire!!!

Emeke Ajeh Godofbrowser

🔥
Setting browsers on fire!!!
View GitHub Profile
@Godofbrowser
Godofbrowser / react-native-metro
Created September 18, 2019 08:10
Reconnect to network after device disconnect from react=native development server (metro)
Check that the device is reconnected to the machine with:
`adb devices`
Reroute the connection to the development server with:
`adb reverse tcp:8081 tcp:8081`
@Godofbrowser
Godofbrowser / a-short-ajax-error-story-1-of-4.js
Last active November 11, 2019 22:04
This gist is part of an article and may not covey the actual message on it's own. Link to article: https://medium.com/@ejjay/a-short-ajax-story-on-error-handlers-8baeeccbc062
import axios from 'axios';
import {notifier} from './util';
// Fetch some missing information
axios.get('/api/articles/not-found').then(resp => {
// So something with article information
}).catch(error => {
const statusCode = error.response ? error.response.status : null;
@Godofbrowser
Godofbrowser / a-short-ajax-error-story-4-of-4.ts
Last active November 11, 2019 22:04
This gist is part of an article and may not covey the actual message on it's own. Link to article: https://medium.com/@ejjay/a-short-ajax-story-on-error-handlers-8baeeccbc062
import axios, {AxiosError} from 'axios';
import {notifier} from './util';
interface ComposedError {
readonly message: string;
readonly error: AxiosError;
handleGlobally(): void;
getError(): AxiosError;
}
@Godofbrowser
Godofbrowser / a-short-ajax-error-story-3-of-4.js
Last active November 11, 2019 22:04
This gist is part of an article and may not covey the actual message on it's own. Link to article: https://medium.com/@ejjay/a-short-ajax-story-on-error-handlers-8baeeccbc062
import axios from 'axios';
import {notifier} from './util';
// errorComposer will compose a handleGlobally function
const errorComposer = (error) => {
return () => {
const statusCode = error.response ? error.response.status : null;
if (statusCode === 404) {
notifier.error('The requested resource does not exist or has been deleted')
}
@Godofbrowser
Godofbrowser / a-short-ajax-error-story-2-of-4.js
Last active November 11, 2019 22:04
This gist is part of an article and may not covey the actual message on it's own. Link to article: https://medium.com/@ejjay/a-short-ajax-story-on-error-handlers-8baeeccbc062
import axios from 'axios';
import {notifier} from './util';
axios.interceptors.response.use(undefined, function (error) {
const statusCode = error.response ? error.response.status : null;
if (statusCode === 404) {
notifier.error('The requested resource does not exist or has been deleted')
}