Commit b954191f authored by Paul Bird's avatar Paul Bird

Replace operateAPIUtilities.swift

parent 1cf4f2b8
......@@ -87,11 +87,15 @@ class operateAPIUtilities {
forHTTPHeaderField: "Content-Type")
let deleteBody = "itemid=\(id)"
request.httpBody = deleteBody.data(using: String.Encoding.utf8)
let req: URLRequest = request as URLRequest
let task = URLSession.shared.dataTask(with: req, completionHandler: { data, response, error in
// set up the session
let config = URLSessionConfiguration.default
config.httpShouldSetCookies = false
let session = URLSession(configuration: config)
let task = session.dataTask(with: req, completionHandler: { data, response, error in
if let httpStatus = response as? HTTPURLResponse,
httpStatus.statusCode != 200 {
......@@ -113,7 +117,12 @@ class operateAPIUtilities {
let req = deleteRequest(endpoint: "note", id: id)
let task = URLSession.shared.dataTask(with: req, completionHandler: { data, response, error in
// set up the session
let config = URLSessionConfiguration.default
config.httpShouldSetCookies = false
let session = URLSession(configuration: config)
let task = session.dataTask(with: req, completionHandler: { data, response, error in
if let httpStatus = response as? HTTPURLResponse,
httpStatus.statusCode != 200 {
......@@ -149,7 +158,12 @@ class operateAPIUtilities {
let req: URLRequest = request as URLRequest
let task = URLSession.shared.dataTask(with: req, completionHandler: { data, response, error in
// set up the session
let config = URLSessionConfiguration.default
config.httpShouldSetCookies = false
let session = URLSession(configuration: config)
let task = session.dataTask(with: req, completionHandler: { data, response, error in
guard error == nil && data != nil else {
//handle errors here
......@@ -200,7 +214,12 @@ class operateAPIUtilities {
let req: URLRequest = request as URLRequest
let task = URLSession.shared.dataTask(with: req, completionHandler: { data, response, error in
// set up the session
let config = URLSessionConfiguration.default
config.httpShouldSetCookies = false
let session = URLSession(configuration: config)
let task = session.dataTask(with: req, completionHandler: { data, response, error in
guard error == nil && data != nil else {
print("error=\(String(describing: error))")
......@@ -262,11 +281,9 @@ class operateAPIUtilities {
// set up the session
let config = URLSessionConfiguration.default
config.timeoutIntervalForRequest = 10
config.httpShouldSetCookies = false
let session = URLSession(configuration: config)
//let task = URLSession.shared.dataTask(with: req, completionHandler: { data, response, error in
let task = session.dataTask(with: req, completionHandler: { data, response, error in
print("req.allHTTPHeaderFields.debugDescription")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment