mardi 27 juin 2017

How to pass alert trough route.js in ember

I've made a function in order to confirm a mail adress. I would like to show a toaster alert when the user confirm is mail. Howwver, i'm stuck in the route/users/confirmation.js and i dont know how to pass it trough a component from there.

import ApplicationRoute from '../../routes/application';
import Ember from 'ember';
import ENV from "../../config/environment";

export default ApplicationRoute.extend({
  beforeModel(params) {
    const confirmationToken = params.queryParams.confirmation_token;

    // Call backend with confirmation token
    Ember.$.ajax({
      url: ENV.API_HOST + '/users/confirmation?confirmation_token=' + confirmationToken,
      type: 'GET',
      headers: {
        'x-api-key': ENV.APP.api_key
      }
    this.transitionTo('app');

    return {};
  }
});

I've been thinking of passing params trough the transitionTo but it appear to be a little bit unsuited..




Aucun commentaire:

Enregistrer un commentaire