Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1f1cad8

Browse files
Søren Louv-Jansencaitp
Søren Louv-Jansen
authored andcommitted
docs(ngMock): fix example for $http respond() helper with function as 1st param
The `whenPOST` method should return a response object containing status, response body and headers. If omitted the following error will be thrown: `Uncaught TypeError: Cannot read property '2' of undefined` The documentation doesn't make it very clear, so I think it will be appropriate to add it here. Closes #6761
1 parent e1f1d65 commit 1f1cad8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ngMock/angular-mocks.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,9 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
17931793
*
17941794
* // adds a new phone to the phones array
17951795
* $httpBackend.whenPOST('/phones').respond(function(method, url, data) {
1796-
* phones.push(angular.fromJson(data));
1796+
* var phone = angular.fromJson(data);
1797+
* phones.push(phone);
1798+
* return [200, phone, {}];
17971799
* });
17981800
* $httpBackend.whenGET(/^\/templates\//).passThrough();
17991801
* //...

0 commit comments

Comments
 (0)