Created
March 4, 2022 06:39
-
-
Save lotusirous/571653b6732c5d3bbfac829f884dd2d0 to your computer and use it in GitHub Desktop.
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 | |
let url = URL(string: "http://127.0.0.1:1234")! | |
var request = URLRequest(url: url) | |
request.setValue("application/json", forHTTPHeaderField: "Content-Type") | |
request.setValue("you-value-goes-here", forHTTPHeaderField: "X-API-KEY") | |
let task = URLSession.shared.dataTask(with: request) { data, _, error in | |
if let data = data { | |
print(data) | |
} else if let error = error { | |
print("Http failed: \(error)") | |
} | |
} | |
task.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment