NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

Post 200 with username & Password login

Forums > SwiftUI

I am having a very hard time in finding any informaiton on how I can do a Post by logging into the server with these parameters

let parameters: Parameters = ["username": username, "password": password]

and my return from the server would be

if let userID = jsonResponse["user_id"] as? String, let customerID = jsonResponse["customer_id"] as? String

Can someone please help me on where I can this information.

   

Hello, without 3rd party libraries you can use URLSession. For example like in this gist - https://gist.github.com/dmathewwws/63064a4114fba3769448602208f66c0d#file-urlsession-post-swift-L26-L27

You can get an app like Postman, Paw and similar to test sending POST requests before implementing them to validate that server responds correctly.

   

AFTER viewing this video I was able to understand how it works. Here is the video for anyone who wants to understand Post 200 https://www.youtube.com/watch?v=hDlPaOQOlHs&t=232s

   

Hacking with Swift is sponsored by Instabug

SPONSORED Catch bugs as soon as they happen and know exactly why a crash occurred. Instabug's SDK grabs all the logs they need to fix bugs, crashes and performance issues in minutes instead of days. Get screenshots, device details, network logs, repro steps, and tons of other critical insights needed to resolve issues and prioritize product backlogs straight from your dashboard. It only takes a minute to integrate!

Get started now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.