Canjs 3.2.1 can-connect behavior loading issue

I’m trying to use the can-connect to retrieve some data from the server and it does not allow me to use the getData method or any of the methods in the url object. I tried making getData into a function instead of a string and it throws the same error.

I am using stealJs.

import connect from 'can-connect/base/base';
import constructor from 'can-connect/constructor/constructor';
import dataUrl from 'can-connect/data/url/url';

var auth = connect([
    constructor,
    dataUrl
],{
    url: {
        getListData: "GET /todos",
        getData: "GET /todos",
        createData: "POST /todos",
        updateData: "PUT /todos/{id}",
        destroyData: "DELETE /todos/{id}"
    },
});

console.log( auth );
console.log( auth.getData() ); //getData is not a function

export { auth };

` The error:

TypeError: Error loading "scripts/main" at /scripts/main.js(…) "TypeError: Error loading "scripts/main" at /scripts/main.js
s.getData is not a function

Console.log( auth ); //returns

o
__behaviorName:"base"
id:(i)
idProp:"id"
init:()
listSet:(i)
listSetProp:
"__listSet"
__proto__:Array[2]

Thanks in advance!

:grinning: Update. I found out that the issue was that I was importing can-connect incorrectly.

It is supposed to be:

import connect from 'can-connect/';

1 Like