Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

340
Visualizações
i have this error :exceeded maximum execution time (line 0)?

I call the api to search into the json based on skus ,the user will put the sku and the start time ,dthen the function will bee count how many orders we have for this sku on this day

This is my code:

// to call the page 
    function firstCall(pag,start){
    
    
      try{

    var url ='https://*****************************?Page=' + pag + '&shopId%5B%5D=90841&pageSize=250' + '&' + 'minOrderDate='+ start;
        var res =UrlFetchApp.fetch(url);
        var content = res.getContentText();
        
        var json= JSON.parse(content);
       
    var node = json.data;
    
     return node;
    
    
      }
      catch(err){
          return "Error getting data" + err;
      }
    }
    
    //to count how many order per day and per sku
    function getInven3(sKu,start){
     if(start == "")  return "!";
     start ="2021-11-17T";
    
      try{
        
    
    
          var url ='https://*********************************?shopId%5B%5D=90841&pageSize=250' + '&' + 'minOrderDate='+ start;
    
        var res = UrlFetchApp.fetch(url);
        var content = res.getContentText();
        var json = JSON.parse(content);
    
    
      var count =0 ;
      var count_tow =0 ;
    
    
      if (json.paging.TotalPages===1){
     for (var i=0; i<firstCall(1,start).length; i++) {
      if(firstCall(1,start)[i].state == 7){
      for (var j=0; j<firstCall(1,start)[i].orderItems.length; j++) {
        var node3=firstCall(1,start)[i].orderItems[j].product.sku;
    
    
     if ((node3 == sKu)) {
         
       
     count++;
    
     } 
       
     }
     
     
      }
      
     }
     return count;
        
      
    
    
      
     
    
    
      }
     else  if (json.paging.TotalPages>1)
                    {
                      console.log("2 page");
    var d=0;
    for (var x = 0, ln = json.paging.TotalPages; x < ln; x++) {
    
    
    
      d++;
      if(d<=json.paging.TotalPages){
    
                                               
                     
        for (var i=0; i<firstCall(d,start).length; i++) {
       
      
      if(firstCall(d,start)[i].state == 7){
      for (var j=0; j<firstCall(d,start)[i].orderItems.length; j++) {
        var node3=firstCall(d,start)[i].orderItems[j].product.sku;
    
      
    
     if ((node3 == sKu)) {
            
       
      count_tow++;
    
       
       
     }
     
     
      }
       
     
    
        
      }
      
      }
    
      }
     }
        return count_tow;
      }
      }
      catch(err){
          return "Error getting data" + err;
      }
    }
    

Error messages keep saying "Exceeded maximum execution time (line 0)."

Could anyone help? Thank you a lot!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda