I'm currently facing an issue with passing a query string from Swift to Express. I am sending [String: Any] data in the following manner:
let params = ["id": 1]
The function I'm sending it to is performing the following actions:
postString = ""
for param in params {
postString += "\(param.key)=\(content)"
if params.count > 1 && i < params.count {
postString += "&"
}
}
let url = URL(string: "http://localhost:8080/api?" + postString)
guard let requestUrl = url else { fatalError() }
var request = URLRequest(url: requestUrl)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
let (data, response) = try await URLSession.shared.data(for: request)
When transferring this to Express, I'm receiving all the parameters I'm passing, but they're being displayed as strings. Here is the request object:
originalUrl: '/api?id=13',
query: { id: '13' },
Is there a proper way to send an integer through the query string? Any assistance would be greatly appreciated. Thank you.