Browse Source

fix for loop

Pablo Barrera Yaksic 11 months ago
parent
commit
51cc628160

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "bot-noticias",
-  "version": "0.0.2",
+  "version": "0.0.3",
   "description": "Bot que busca noticias y las replica en mastodon.cl",
   "main": "dist/index.js",
   "scripts": {

+ 1 - 1
src/portales/elciudadano/handler.ts

@@ -37,7 +37,7 @@ export const handler: Handler = async (event, context) => {
     const length = articles.length;
 
     // Order has to be reverser to appear in the correct order when posting
-    for (let i = length; i > length; i--) {
+    for (let i = length - 1; i >= 0; i--) {
       const article = articles[i];
       const exists = await redisClient.retrieve(article.link);
       if (exists !== null) {

+ 1 - 1
src/portales/eldesconcierto/handler.ts

@@ -37,7 +37,7 @@ export const handler: Handler = async (event, context) => {
     const length = articles.length;
 
     // Order has to be reverser to appear in the correct order when posting
-    for (let i = length; i > length; i--) {
+    for (let i = length - 1; i >= 0; i--) {
       const article = articles[i];
       const exists = await redisClient.retrieve(article.link);
       if (exists !== null) {

+ 1 - 1
src/portales/emol/handler.ts

@@ -37,7 +37,7 @@ export const handler: Handler = async (event, context) => {
     const length = articles.length;
 
     // Order has to be reverser to appear in the correct order when posting
-    for (let i = length; i > length; i--) {
+    for (let i = length - 1; i >= 0; i--) {
       const article = articles[i];
       const exists = await redisClient.retrieve(article.link);
       if (exists !== null) {

+ 1 - 1
src/portales/latercera/handler.ts

@@ -39,7 +39,7 @@ export const handler: Handler = async (event, context) => {
     const length = articles.length;
 
     // Order has to be reverser to appear in the correct order when posting
-    for (let i = length; i > length; i--) {
+    for (let i = length - 1; i >= 0; i--) {
       const article = articles[i];
       const exists = await redisClient.retrieve(article.link);
       if (exists !== null) {

+ 1 - 1
src/portales/theclinic/handler.ts

@@ -37,7 +37,7 @@ export const handler: Handler = async (event, context) => {
     const length = articles.length;
 
     // Order has to be reverser to appear in the correct order when posting
-    for (let i = length; i > length; i--) {
+    for (let i = length - 1; i >= 0; i--) {
       const article = articles[i];
       const exists = await redisClient.retrieve(article.link);
       if (exists !== null) {