Skip to content

How to create a global function that can access over full adonis app and also edge file. #4587

Answered by emrancu
emrancu asked this question in Help
Discussion options

You must be logged in to vote

1. Create a ts file and add to preload on adonisrc.ts on root

  preloads: [() => import('path'))

In your custom file:

import edge from 'edge.js'

and set like:

const getData = ()=> return 'ok'

edge.global('getData', getData)

Now You can Access from .edge file like:

 {{ getData() }}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@emrancu
Comment options

Answer selected by emrancu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants