Skip to content

Instantly share code, notes, and snippets.

View hero9's full-sized avatar
:shipit:
Focusing

Galymzhan Almabek hero9

:shipit:
Focusing
  • localhost
  • Prague
  • 19:13 (UTC +02:00)
View GitHub Profile
Step 1: On the front-end, get the 3rd party authentication provider login popup to appear.
Step 2: (Still on the front-end) Grab the access token the provider returns after agreeing to login.
Step 3: (Yep, still front-end) Send that token to the back-end as part of the input argument of your mutation.
Step 4: On the back-end, verify the token.
Step 5: If the token is authentic, you will receive the user as part of the verification response (at least that’s the case with Passport.js, which we’ll be using).
@hero9
hero9 / useExportExcel.ts
Last active April 19, 2022 10:53
React custom hook, which exports data to excel!
import * as XLSX from 'xlsx';
import FileSaver from 'file-saver';
// Pass tree: true if want to get excel with multiple pages
export const useExportData = (fileName: string, csvData: any, tree?: boolean) => {
let ws: XLSX.WorkSheet;
const fileType =
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
const fileExtension = '.xlsx';