Skip to content

Impossible to call window.fetch without RequestInit #24

@eymar

Description

@eymar

With 0.5.0 version, some API (e.g. window.fetch, cache.match) do not allow option-less calls (when compiling to k/js).

Without kotlinx-browser it used to be possible to call just window.fetch(resPath).
But now there is an error: [NO_VALUE_FOR_PARAMETER] No value passed for parameter 'init'.

Adding an empty init leads to another error.

val response = window.fetch(resPath, RequestInit())

CoroutineExceptionHandlerImpl.kt:7 TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'cache' property from 'RequestInit': The provided value 'null' is not a valid enum value of type RequestCache.

val response = window.fetch(resPath, RequestInit(cache = RequestCache.NO_CACHE))

TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'credentials' property from 'RequestInit': The provided value 'null' is not a valid enum value of type RequestCredentials.

And etc...

At the same time, k/wasm target compiles and works as usual.


Looks like it's related to #17, but still here we have a different issue with k/js that a plain API call without init is not possible right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions