Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓

Humberto Dib Rayashi rayashi

🤓
View GitHub Profile
View UserDetail.js
import React from "react";
import ContentLoader from "./ContentLoader";
import { useParams } from "react-router-dom";
export default ({ userId }) => {
let { id } = useParams();
const getUserDetail = async () => {
return await (
View UserList.js
import React from "react";
import ContentLoader from "./ContentLoader";
import { Link } from "react-router-dom";
export default () => {
const getUsers = async () => {
return await (await fetch("https://reqres.in/api/users?delay=1")).json();
};
return (
View ContentLoader.js
import React from "react";
export default ({ render, getContent }) => {
const [loading, setLoading] = React.useState(false);
const [content, setContent] = React.useState(null);
React.useEffect(() => {
async function load(){
setLoading(true);
View settings.py
INSTALLED_APPS = [
...
'rest_framework',
'rest_framework.authtoken'
]
@rayashi
rayashi / signals.py
Last active Aug 11, 2019
Catching post_save signal to create a token
View signals.py
from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver
from rest_framework.authtoken.models import Token
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
Token.objects.create(user=instance)