Skip to content
Gx
GitHub

GX4009: action method cannot be invoked from the client

An on: directive invokes an action whose HTTP method the browser adapter cannot send.

Cause

An on: directive invokes an action whose HTTP method the browser adapter cannot send.

Example

cart/Button.gx
package cart

import "app/cart/route"

<button on:click={route.Add{}}>Add</button>
cart/cart.go
package cart

import (
	"github.com/alternayte/gx"
	"app/cart/route"
)

var Add = gx.Action(func(c *gx.Ctx, in route.Add) error { return nil })
cart/route/route.go
package route

import "github.com/alternayte/gx"

type Add struct {
	gx.Route `OPTIONS /cart/add`
}

gx check reports:

gx check
cart/Button.gx:5:9: GX4009: method OPTIONS of "Add" cannot be invoked from the client

Fix

Use GET, POST, PUT, PATCH or DELETE in the route tag.