dimanche 21 août 2022

could not find module 'ember-resources'

am trying to build an web app with ember and in the process of making a request to server and receiving a response and for that i used resources from ember-resource yet it always popping the error module not found ember-resources

the js code

import { use, resource } from 'ember-resources';
import { tracked } from '@glimmer/tracking';

class RequestState {
  @tracked value;
  @tracked error;

  get isPending() {
    return !this.error && !this.value;
  }
}

export default class RoomselectController extends Controller {
    @service router;

    @use request = resource(({ on }) => {
      const mobile = '123123123';
      const state = new RequestState();
    
      $.ajax({
        url: 'My',
        method: 'GET',
        dataType: 'json',
        data: { mobile },
        success: (response) => state.value = response;,
        error: (xhr, status, error) => state.error = `${status}: ${xhr.statusText}`,
      });

      return state;
    });

    get result() {
      return this.request.value || [];
    }

}

i installed ember-resource using ember install ember-resources also done npm install ember-resources

still showing the same module not found errro what to do?




Aucun commentaire:

Enregistrer un commentaire