How to use the angular-in-memory-web-api.STATUS.NO_CONTENT function in angular-in-memory-web-api

To help you get started, we’ve selected a few angular-in-memory-web-api 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 johnpapa / angular-ngrx-data / src / in-memory-data.service.ts View on Github external
const changes = changeSet.changes;
    changes.forEach(item => {
      // Only know how to delete villains
      if (item.entityName === 'Villain') {
        const deleteIds = item.entities as number[];
        this.db['villains'] = this.db['villains'].filter(v => !deleteIds.includes(v.id));
      }
    });

    // In this example, the server processes the request
    // w/o changing the data that it inserts or updates.
    // There's no reason to expect the server to return anything.
    // So this API responds with 204-No Content and no body.
    const options: ResponseOptions = {
      url: requestInfo.url,
      status: STATUS.NO_CONTENT,
      statusText: 'NO CONTENT',
      body: null
    };

    // But if it did return updated entities it might respond with this
    // const options: ResponseOptions = {
    //   url: requestInfo.url,
    //   status: STATUS.OK,
    //   statusText: 'OK',
    //   body: changeSet
    // };

    return requestInfo.utils.createResponse$(() => options);
  }
}