Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
28 changes: 0 additions & 28 deletions swift_heart_rate_real_time-master/ElecDemo/APIFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,3 @@
// Created by NhatHM on 8/13/19.
// Copyright © 2019 GST.PID. All rights reserved.
//

import Foundation

class APIFetcher {
let defaultSession = URLSession(configuration: URLSessionConfiguration.default)
var dataTask: URLSessionDataTask?

func postHeartRateToServer(url: String, completion: @escaping (String?) -> ()) {

let url: URL = URL(string: url)!

dataTask = defaultSession.dataTask(with: url) { data, response, error in
if let error = error {
print(error.localizedDescription)
completion(nil)
} else if let httpResponse = response as? HTTPURLResponse {
if httpResponse.statusCode == 200 {
completion("Sucess get data from server")
} else {
print("\(httpResponse.statusCode)")
completion(nil)
}
}
}

dataTask?.resume()
}
}