Created
July 13, 2021 18:37
-
-
Save simrandotdev/397ca4579a0dd9d1c8131b70b9b3d691 to your computer and use it in GitHub Desktop.
LOTR token in Header example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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