[WASM] How can I perform a set of crud REST api with tinygo ? #4127
Unanswered
SBoucard-dev
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently working on a personal project. Notably to discover the possibilities of Web Assembly and Tinygo.
I have a small project which use vanilla.js and a simple index.html containing a button. When I click on the button, it execute my wasm module method
getBookByIdwhich is exposed through my index.js file.I have partially succeed in requesting an endpoint of my localhost backend server.
main.go (front) :
main.go (back) :
I have the following log in my backend running with gin :
[GIN] 2024/02/13 - 16:49:15 | 200 | 476.625µs | 127.0.0.1 | GET "/books/1"
And I can see in the browser "network" section, the response status from the server (200 OK)
response content:
{ "id": "1", "title": "Sample title 1", "author": "Joe" }But in my browser console, I have the following error :
panic: runtime error: nil pointer dereference main.wasm:0x55925 Uncaught (in promise) RuntimeError: unreachable at runtime.runtimePanicAt (main.wasm:0x55925) at runtime.nilPanic (main.wasm:0x775f) at runtime.chanSelect (main.wasm:0x71087) at interface:{RoundTrip:func:{pointer:named:net/http.Request}{pointer:named:net/http.Response,named:error}}.RoundTrip$invoke (main.wasm:0x1d5856) at getBookByID (main.wasm:0x202e02) at getBookByID.command_export (main.wasm:0x204c70) at getBookById (index.js:40:50) at async HTMLButtonElement.<anonymous> ((index):161:24)Is it due to a bad return type format ? Do I need to return my json as a string ?
Beta Was this translation helpful? Give feedback.
All reactions