Skip to content

Instantly share code, notes, and snippets.

@simrandotdev
Created July 13, 2021 18:37
Show Gist options
  • Save simrandotdev/397ca4579a0dd9d1c8131b70b9b3d691 to your computer and use it in GitHub Desktop.
Save simrandotdev/397ca4579a0dd9d1c8131b70b9b3d691 to your computer and use it in GitHub Desktop.
LOTR token in Header example
import UIKit
var request = URLRequest(url: URL(string: "https://the-one-api.dev/v2/movie")!)
request.addValue("Bearer <Replace this with your Token for the API>", forHTTPHeaderField: "Authorization")
URLSession.shared.dataTask(with: request) { data, response, error in
guard error == nil,
let data = data else {
print(error)
return
}
print(String(data: data, encoding: .utf8) ?? "")
}.resume()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment