I have looked at other posts here but still can't resolve my issue.
I get a Error:
$resource:badcfg Response does not match configured parameter
I believe this error is caused by it returning an array rather than an object or vice versa.
Here's my code:
Inside my factory(I added the isArray: false but still not luck)
var task = $resource('http://localhost:5000/task/:id', {id:'@id'}, {
'get': {method:'GET', isArray: false},
});
Then in the return section of my factory
find: function(id){
return task.get({ id: id });
}
In my Flask server it does the correct response when I load the page:
127.0.0.1 - - [28/Feb/2017 14:35:13] "GET /task/1 HTTP/1.1" 200 -
However I still get the error?
Also this is what my server provides if i put it in the browser http://localhost:5000/task/1
[{"completed": true, "id": 1, "ownerName": "Ryan", "task": "Test Activity", "title": "A test task"}]
Iv also tried this and get the same error:
console.log(task.get({ id: 1 }));
The default actions for $resource are:
Avoid changing the default method:
Instead use the
queryaction method:This will avoid confusing programmers that are familiar with the conventions of the $resource service.
For more information, see AngularJS $resource API Reference.
Using
transformResponseto Extract Object from ArrayIf the server is erroneously returning the resource object enclosed in an array, it can be extracted with a response transform function: