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

Conversation

ghost
Copy link

@ghost ghost commented Mar 5, 2019

// 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;
  }

// 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 collection = this.news.slice(page * (limit - 1), 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
Copy link

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).

📝 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.

@ghost ghost closed this by deleting the head repository Oct 6, 2023
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant