How to use the @angular/http.ResponseOptions function in @angular/http

To help you get started, we’ve selected a few @angular/http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gazbert / bxbot-ui-angular / src / app / model / bot / bot-http-data-promise.service.spec.ts View on Github external
it('should handle returning no Bot', async(inject([], () => {
            let resp = new Response(new ResponseOptions({status: 200, body: {data: []}}));
            backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
            service.getBot(100) // unknown id
                .then(bot => expect(bot.id).not.toBeDefined('should have no Bot'));
        })));
    });
github Teradata / covalent / src / platform / http-deprec / interceptors / http-interceptor.service.spec.ts View on Github external
onResponse(response: Response): Response {
    return new Response(new ResponseOptions({ body: JSON.stringify('override'), status: 200 }));
  }
}
github dotCMS / core-web / src / dotcms-js / core / util / jwt-auth.service.spec.ts View on Github external
backend.connections.subscribe((connection: MockConnection) => {
            let options = new ResponseOptions({
                body: JSON.stringify({
                    'entity': {
                        'token': 'This is a Auth Token'
                    },
                }),
                status: 200
            });
            let a = new Response(options);
            connection.mockRespond(a);
        });
github dotCMS / core-web / src / app / api / services / paginator / paginator.service.spec.ts View on Github external
items: [
                { id: 0, name: 'Name 0' },
                { id: 1, name: 'Name 1' },
                { id: 2, name: 'Name 2' },
                { id: 3, name: 'Name 3' }
            ],
            totalRecords: 5
        };

        this.paginatorService.get().subscribe((items) => {
            this.result = items;
        });

        this.lastConnection.mockRespond(
            new Response(
                new ResponseOptions({
                    body: JSON.stringify({
                        entity: fakeEntity
                    }),
                    headers: new Headers({
                        Link: headerLink,
                        'X-Pagination-Current-Page': '3',
                        'X-Pagination-Link-Pages': '5',
                        'X-Pagination-Per-Page': '10',
                        'X-Pagination-Total-Entries': '38'
                    })
                })
            )
        );
    });
github ovh / cds / ui / src / app / shared / variable / form / variable.form.spec.ts View on Github external
backend.connections.subscribe(connection => {
            connection.mockRespond(new Response(new ResponseOptions({ body : '["string", "password"]'})));
        });
github accordproject / concerto / packages / composer-playground / src / app / github / github.component.spec.ts View on Github external
mockBackend.connections.subscribe((connection) => {
                    connection.mockRespond(new Response(new ResponseOptions({
                        body: JSON.stringify(mockResponse)
                    })));
                });
github dotCMS / core-web / src / app / api / services / dot-content-type / dot-content-type.service.spec.ts View on Github external
function mockConnectionContentletResponse(): void {
    return lastConnection.mockRespond(
        new Response(
            new ResponseOptions({
                body: {
                    entity: mockDotContentlet
                }
            })
        )
    );
}
github bulktrade / SMSC / modules / admin / src / app / shared / components / delete-resource / delete-resource.component.spec.ts View on Github external
mockBackend.connections.subscribe(connection => {
            let response = new ResponseOptions({body: {id: 1}});
            connection.mockRespond(new Response(response));
        });
        spyOn(componentFixture.instance.notification, 'createNotification');
github chaibio / chaipcr / ng2 / src / app / services / session / session.service.spec.ts View on Github external
backend.connections.subscribe((connection: MockConnection) => {
          connection.mockError(new MockError(new ResponseOptions(mockResponse)));
        });
github angular / universal / examples / next-hello-world / src / universal_modules / platform-node / node-http.ts View on Github external
let onError = (err) => {
        let responseOptions = new ResponseOptions({body: err, type: ResponseType.Error});
        if (isPresent(baseResponseOptions)) {
          responseOptions = baseResponseOptions.merge(responseOptions);
        }
        ngZone.run(() => {
          responseObserver.error(new Response(responseOptions));
        });
      };