I have a token that contains the generated json web token. I was trying to pass it to a json encoder to be passed to the client.
token := "generatedtoken"
json.NewEncoder(res).Encode(`{ success: true, message: "Successfully logged in." }`)
I have a token that contains the generated json web token. I was trying to pass it to a json encoder to be passed to the client.
token := "generatedtoken"
json.NewEncoder(res).Encode(`{ success: true, message: "Successfully logged in." }`)
you can do:
token := "sometoken"
response := map[string] interface{} {
"success":true,
"message": "Successfully logged in.",
"token": token}
json.NewEncoder(res).Encode(&response)
or you can wrap the response in a struct.