gatsby-source-sanity
Version:
Gatsby source plugin for building websites using Sanity.io as a backend.
18 lines • 546 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const through = require("through2");
function filter(sanityDoc, enc, callback) {
const doc = sanityDoc;
if (doc._id && doc._type) {
callback(null, doc);
return;
}
const error = sanityDoc;
if (error.statusCode && error.error) {
callback(new Error(`${error.statusCode}: ${error.error}`));
return;
}
callback();
}
exports.rejectOnApiError = () => through.obj(filter);
//# sourceMappingURL=rejectOnApiError.js.map