Hi there,
Just wondering if anyone else is having difficulty with the yelp API, I used the one which was provided but getting the status: 400. Ive doubled checked the code but still getting this error. any help would be great
import Foundation
struct DataService {
let apiKey = Bundle.main.infoDictionary?["API_KEY"] as? String
func businessSearch() async {
// Check if API exists
guard apiKey != nil else {
return
}
// 1. Create URL
if let url = URL(string: "https://api.yelp.com/v3/businesses/search?latitude=35.665517&longitude=139.770398&categories=restaurants&limit=10") {
// 2. Create request
var request = URLRequest(url: url)
request.addValue("Bearer \(apiKey!)", forHTTPHeaderField: "Authorization")
request.addValue("applicatuion/json", forHTTPHeaderField: "accept")
// 3. Send request
do {
let (data, response) = try await URLSession.shared.data(for: request)
print(data)
print(response)
} catch {
print(error)
}
}
}
}