MCPcopy Create free account
hub / github.com/apache/pouchdb / fetchData

Function fetchData

lib/index-browser.js:7169–7200  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

7167 // which we cannot parse. Also, this is more efficient than
7168 // receiving attachments as base64-encoded strings.
7169 async function fetchData(filename) {
7170 const att = atts[filename];
7171 const path = encodeDocId(doc._id) + '/' + encodeAttachmentId(filename) +
7172 '?rev=' + doc._rev;
7173
7174 const response = await ourFetch(genDBUrl(host, path));
7175
7176 let blob;
7177 if ('buffer' in response) {
7178 blob = await response.buffer();
7179 } else {
7180 /* istanbul ignore next */
7181 blob = await response.blob();
7182 }
7183
7184 let data;
7185 if (opts.binary) {
7186 const typeFieldDescriptor = Object.getOwnPropertyDescriptor(blob.__proto__, 'type');
7187 if (!typeFieldDescriptor || typeFieldDescriptor.set) {
7188 blob.type = att.content_type;
7189 }
7190 data = blob;
7191 } else {
7192 data = await new Promise(function (resolve) {
7193 blobToBase64(blob, resolve);
7194 });
7195 }
7196
7197 delete att.stub;
7198 delete att.length;
7199 att.data = data;
7200 }
7201
7202 const promiseFactories = filenames.map(function (filename) {
7203 return function () {

Callers 3

fetchAttachmentsFunction · 0.70
fetchedFunction · 0.70
HttpPouchFunction · 0.70

Calls 8

encodeDocIdFunction · 0.70
encodeAttachmentIdFunction · 0.70
ourFetchFunction · 0.70
genDBUrlFunction · 0.70
blobToBase64Function · 0.70
paramsToStrFunction · 0.70
setupFunction · 0.70
fetchJSONFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…