Я делаю PWA с VUE и VUEX.Все в порядке, пока я не попробую автономное приложение, поскольку я в действии VUEX не могу разрешить запросы из кеша.
Если я не использую VUEX, запросы от компонента хорошо передаются в кеш, но с VUEX я получаюошибка:
GET https://api.mercadolibre.com/items/MLM580205144 net :: ERR_FAILED
Это код запроса в VUEX:
actions.js:
for ( var x = 0; x <= json.results.length; x ++ ){
if(json.results[x] !== undefined){
var dataOfProduct = {
id:'',
product:'',
description:{
model:'',
desc:'',
title:''
}
};
const dataItem = await fetch('https://api.mercadolibre.com/items/' + json.results[x].id );
const jsonItem = await dataItem.json();
const dataDesc = await fetch('https://api.mercadolibre.com/items/' + json.results[x].id + '/description');
const jsonDesc = await dataDesc.json();
dataOfProduct.id = json.results[x].id;
dataOfProduct.product = jsonItem;
if( jsonDesc.status === 404){
jsonDesc.plain_text = 'Producto: No definido. Modelo: No definido'
}
let text = jsonDesc.plain_text;
dataOfProduct.description.desc = text;
const product = 'Producto:';
let resultProduct = text.match(new RegExp(product + '\\s(\\w+)', 'i'));
if (resultProduct != null) {
resultProduct = resultProduct[1];
}
const model = 'Modelo:';
let resultModel = text.match(new RegExp(model + '\\s(\\w+)', 'i'));
if (resultModel != null) {
resultModel = resultModel[1];
}
dataOfProduct.description.title = resultProduct;
dataOfProduct.description.model = resultModel;
}
allProducts.push( dataOfProduct );
}
![error fetch with vuex](https://i.stack.imgur.com/XT6Hm.png)