You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to figure out how to use JSObject.global.fetch.function! along with JSPromise to assemble a PUT request with a body and headers. I keep falling flat on my face 😣 I am able to use fetch and preform GET requests, parse the JSON, and the whole-nine-yards, but I don't understand where to go for sending data.
I have tried assembling a params object using something like this JSObject.construct(from: ["method": "PUT", "body": json.jsString].jsValue) and passing it as a second parameter to fetch. Doing this though, when handling the .then statement I receive an error of:
/Users/lorenalexm/Projects/SwiftScheduleCheck/Sources/SwiftScheduleCheck/Views/ContentView.swift:118:16: Cannot convert value of type '()' to closure result type 'ConvertibleToJSValue'
Might anyone help provide a bit of guidance on how to proceed from here? Thank you!
The text was updated successfully, but these errors were encountered:
Also note the use of json.object!.json, it's a peculiarity of httpbin, which I used to test this. It wraps the response in a top-level JSON structure, having body in the inner json property. You may need to use json instance directly with other services instead.
@MaxDesiatov I am so sorry for the delay in replying. Thank you so much for the explanation and code snippet, this really helped me work through my issue and build a reusable class for making network requests in my Tokamak projects! Your assistance has helped resolve my problems, thank you again.
I am trying to figure out how to use
JSObject.global.fetch.function!
along withJSPromise
to assemble a PUT request with a body and headers. I keep falling flat on my face 😣 I am able to usefetch
and preform GET requests, parse the JSON, and the whole-nine-yards, but I don't understand where to go for sending data.I have tried assembling a params object using something like this
JSObject.construct(from: ["method": "PUT", "body": json.jsString].jsValue)
and passing it as a second parameter tofetch
. Doing this though, when handling the.then
statement I receive an error of:Might anyone help provide a bit of guidance on how to proceed from here? Thank you!
The text was updated successfully, but these errors were encountered: