Repository URL to install this package:
|
Version:
7.1.2 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fromHeadersToSerialized_1 = require("./fromHeadersToSerialized");
/**
* @see https://github.com/bitinn/node-fetch/tree/master/src
* @see https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-env/src/index.ts
* @see https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-env/src/index.d.ts *
*/
function fromResponseToSerialized(response) {
const temp = {};
const clean = {};
Object.getOwnPropertySymbols(response).forEach(symbol => {
// String(symbol) !== 'Symbol(Body internals)'
if (!response[symbol].body) {
temp[String(symbol)] = response[symbol];
}
});
// const combined = { ...temp, ...response, ...temp['Symbol(Body internals)'] }
const asResponse = response;
const asOneResponse = response;
if (asResponse.type) {
clean.type = asResponse.type;
}
if (asResponse.status) {
clean.status = asResponse.status;
}
if (asResponse.statusText) {
clean.statusText = asResponse.statusText;
}
if (asResponse.url) {
clean.url = asResponse.url;
}
if (asResponse.headers) {
clean.headers = fromHeadersToSerialized_1.fromHeadersToSerialized(asResponse.headers);
}
if (asOneResponse.data) {
clean.data = asOneResponse.data;
}
if (asOneResponse.prettyError) {
// not that helpful, is on clean already
}
return clean;
}
exports.fromResponseToSerialized = fromResponseToSerialized;
//# sourceMappingURL=fromResponseToSerialized.js.map