gotron icon indicating copy to clipboard operation
gotron copied to clipboard

Can send values to backend?

Open zerofelx opened this issue 5 years ago • 1 comments

Hello I can send strings, booleans, ints or another value or variable to backend? I use the events but I don't understand what is the method to send values, I only can run a code whit a event but without a value from the Frontend

Example: I create a form, the form get Username and password

When click "Send" with a event to backend, the event run the code but don't send the values to golang

How I compare this values with the values in the backend?

Or how i can send the values?

Thanks! :D

zerofelx avatar Jan 09 '20 22:01 zerofelx

Temporal solution:

Javascript Code:

ws.send(JSON.stringify({ event: "Chrome", variables: v })) (v is a parameter of a function)

I added Variables string json:"variables"`` into Event struct I added a global variable into gotron.go var UserVar = make(chan Event) after to Event struct In function "onSocket" after of:

//Handle Message err = json.Unmarshal(message, &event) errz.Fatal(err, "Unmashal: ") logger.Debug().Msgf("ElectronSocket: [received] %+v", event)

I added: go func() { UserVar <- event }()

I call the variable in my code this way: window.On(&Evento, func(bin []byte) { item := <-gotron.UserVar fmt.Println(item.Variables) })

^^

zerofelx avatar Jan 10 '20 03:01 zerofelx