angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 231 forks source link

Angular HttpResponse expected not lib.dom #234

Closed ghost closed 1 year ago

ghost commented 5 years ago

// Example

  get(reqInfo: RequestInfo) {
    if (reqInfo.query.has('page')) {
      const page: number = Number.parseInt(reqInfo.query.get('page')[0], 10);
      const limit: number = reqInfo.query.has('limit') ?
        Number.parseInt(reqInfo.query.get('limit')[0], 10)
        : 10;
      const startIndex = page * limit;
      const collection = this.news.slice(startIndex, startIndex + limit);
      const body = reqInfo.utils.getConfig().dataEncapsulation ? {data: collection} : collection;
      const httpResponse = new HttpResponse({
        body,
        url: reqInfo.url,
        status: 200,
        statusText: 'ok'
      });
      return of(httpResponse);
    }
    return null;
  }
googlebot commented 5 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.