Skip to content

PUT request using Fetch #197

Closed
Closed
@lorenalexm

Description

@lorenalexm

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions