Closed subroh0508 closed 4 years ago
Hi @subroh0508, node-fetch
package is used for node-js modules only. It looks like it selected wrong runtime. I'll take a look on the reproducer first.
@e5l Thank you for your reply!
node-fetch package is used for node-js modules only
As you say, the case specifying js { browser() }
and written entirely in Kotlin was selected window.fetch
. Like blow(and this code can receive response correctly).
https://github.com/subroh0508/ktor-client-mpp-sample/blob/master/web/src/main/kotlin/main.kt#L23
But, the case transpiling JS and using from JS code was selected node-fetch
. Like below(and this code always throws TypeError, so I want to fix it).
I'd like to check, should PlatformUtil.IS_NODE
be false when importing transpiled Kotlin/JS modules from build/js/packages/*
directory and using them in JS code?
Fixed my code 💪
Ktor Version and Engine Used (client or server and name) Version: 1.3.1 Engine: Js-Client
Describe the bug The module specifying
js { nodejs() }
and building called from JavaScript, throws "TypeError".For example, the code blow.
Repository URL: https://github.com/subroh0508/ktor-client-mpp-sample/tree/by-node-fetch
Expected behavior Does not throw any errors on node-fetch environment.
Screenshots