This module provides a decoder middleware to attach a response status to the response data.
import Provider, { provider } from 'core/data';import { attachStatus } from 'core/data/middlewares';@providerexport default class User extends Provider { static decoders = { get: [attachStatus] }; baseURL = 'user/:id';}(async () => { const user = new User(), bob = await user.get('bob').data; // Response status code (number) console.log(bob.status); // User response data console.log(bob.data);})();
Decoder: attaches a response status to response data
core/data/middlewares/attach-status
This module provides a decoder middleware to attach a response status to the response data.