import Toast from '../components/Toast' ; import socket from '../socket' ; export default function fetch < T = any > ( event , data = { } , { toast = true } = { } ) { return new Promise ( ( resolve ) => { socket . emit ( event , data , ( res ) => { if ( typeof res === 'string' ) { if ( toast ) { Toast . danger ( res ) ; } resolve ( [ res , null ] ) ; } else { resolve ( [ null , res ] ) ; } } ) ; } ) ; }