This is really strange. I have a collection called News_Feed and I insert values into them as per the code mentioned below. This was running perfectly a couple of days back, but from last week there was no data that was inserted into this DB collection by the code mentioned below.
Reason which I got from logs -
Error: The News_Feed collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.
This is really strange as the DB is right in front of my eyes and there are other DBs as well that I refer to from the same page and they work seemingly fine.
Anyone who has faced this issue and can help me on this would be much appreciated.
My code:
import wixData from ‘wix-data’;
export function button21_click(event, $w) {
//Add your code for this event here:
let uri = $w(“#input15”).value;
let url = “http://xyz.site” + uri + “&xpath=/body”;
getNewsFeed(url)
.then(news => {
let cnt = news.length;
let pcnt = 0;
while (pcnt !== cnt){
$w("#text343").text = news[pcnt].text;
let totalcnt = $w("#text343").text.length;
let text = $w("#text343").text;
$w("#text343").text = text.replace('\n'," ");
text = $w("#text343").text;
//console.log(text);
let cntr = 0;
let prcnt = 0;
//let totalcnt1=text.length;
var category;
var subCategory;
while (cntr < totalcnt+1){
if(text.charAt(cntr) === " " || cntr === totalcnt)
{
let a = text.slice(prcnt, cntr).trim();
prcnt = cntr;
//console.log(a);
let txt1 = a.replace("[","");
a = txt1;
let txt2 = a.replace("]","");
a = txt2;
let e = a.search("@"); //email
let f = a.search(/\b[A-Fa-f0-9]{64}\b/); //sha-256
//let g = a.search(/\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b/); //ipv4
let g = a.search(/\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b/);
let d = a.search(/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/);//domain
let m = a.search(/\b[a-f0-9]{32}\b/); //md5
let u = a.search(/(?:(?:https?|ftp):\/\/|\b(?:[a-z\d]+\.))(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s!'()\[\]{};:'".,<>?«»“”‘’]))?/);
category = "None";
if(e >0){
category = "Email";
subCategory = "Sender's Address";
}
if(f >0){
category = "File Hash";
subCategory = "SHA-256";
}
if(g >-1){
category = "IP Address";
subCategory = "IPv4";
}
if(d>-1){
category = "Domain / URL";
subCategory = "Domain";
}
if(u>0){
category = "Domain / URL";
subCategory = "URL";
}
if(m>-1){
category = "File Hash";
subCategory = "MD5";
}
if(category !== "None"){
let description = subCategory + " associated with " + $w("#input16").value + " " + $w("#dropdown5").value;
let toInsert = {
"title": $w("#input16").value,
"actualIoc": a,
"category": category,
"subCategory": subCategory,
"srn": $w("#dropdown3").value,
"month": $w("#dropdown6").value,
"malwareCategory": $w("#dropdown4").value,
"malwareSubCategory": $w("#dropdown5").value,
"url": $w("#input15").value,
"description": description,
};
wixData.insert("News_Feed", toInsert) / ***/ toInsert is perfect as per console.logs***
.then( (results) => {
let item = results; //see item below
console.log(results);
})
.catch( (err) => {
let errorMsg = err;
**console.log(errorMsg);** ***// this is where the error message is logged***
Error: The News_Feed collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.
} );
}
cntr++;
} //end if
else{
cntr++;
}
} // end cntr while
pcnt++;
}//end pcnt while
});//end getnewsfeed