Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
migration
by![](https://cdn.sanity.io/images/aho0e32c/production/61b763a05f41a7aea0b3b3265ff0fc83534ef28c-20x21.svg?w=20&fit=max&auto=format)
Codemod
Ember/5/App Controller Router Props
Last update
Jul 24, 2024
This codemod replaces all occurrences of this.currentRouteName
with this.router.currentRouteName
and this.currentPath
with this.router.currentPath
.
Before
import Controller from '@ember/controller';import fetch from 'fetch';export default Controller.extend({store: service('store'),actions: {sendPayload() {fetch('/endpoint', {method: 'POST',body: JSON.stringify({route: this.currentRouteName,}),});},},});
After
import Controller from '@ember/controller';import fetch from 'fetch';export default Controller.extend({router: service('router'),store: service('store'),actions: {sendPayload() {fetch('/endpoint', {method: 'POST',body: JSON.stringify({route: this.router.currentRouteName,}),});},},});
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community