mardi 27 octobre 2015

EmberJS and third-party libraries

I'm trying to implement digest auth in Ember app. To complete this I took this library - http://ift.tt/1BAWLVl. But I have no idea how to use it in an app. Now my auth service looks next:

import Ember from 'ember';

export default Ember.Service.extend({
    path: "some-path",
    username: "",
    password: "",

    me(successHandler) {
        var meRequest = new digestAuthRequest('GET', this.path + "/me", this.username, this.password);
        meRequest.request(successHandler);
    },

    setCredentials(username, password) {
        this.username = username;
        this.password = password;
        console.log(this.username);
    }
});

And I got following errors:

services/auth.js: line 9, col 29, A constructor name should start with an uppercase letter.
services/auth.js: line 9, col 29, 'digestAuthRequest' is not defined.

My only attempt was adding digestAuthRequest.js to vendor folder, and adding

app.import('vendor/digestAuthRequest.js');

to ember-cli-build.js.

Looks like it's completely incorrect. So what I need to do to use such library in Ember app?

P.S. EmberJS version - 1.13.




Aucun commentaire:

Enregistrer un commentaire