Skip to content

Instantly share code, notes, and snippets.

@yi-mei-wang
Created October 16, 2019 15:54
Show Gist options
  • Save yi-mei-wang/8ec03b61fd3eb8a4bb4d2e66d3f4a9c9 to your computer and use it in GitHub Desktop.
Save yi-mei-wang/8ec03b61fd3eb8a4bb4d2e66d3f4a9c9 to your computer and use it in GitHub Desktop.
JWT and Image Upload Lecture
  1. Form validation
  • Disable buttons when the form inputs are empty
  • Show error feedback
  1. JWT in header
  • headers: {Authorization : `Bearer ${authToken}`}
  • What are headers?
  • Bearer token?
    • Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens
    • can be understood as “give access to the bearer of this token.”
    • The bearer token is a cryptic string, usually generated by the server in response to a login request.
    • The client must send this token in the Authorization header when making requests to protected resources Authorization: Bearer <token>
  • How to pass a header using axios?
    • axios.post(url, data, headers).then().catch()
  1. User profile page
  • Send JWT as a bearer token, get their information, display
  1. Image upload
  • Add an upload form
  • Add image preview
    • How does URL.createObjectURL(file) work?
    • Creates a reference to the image
    • Generates a temporary link to the file uploaded
  • Upload image by making the call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment