Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
How get a value from Object in a function inside itself

I'm trying to change/read a variable from an object through functions, which are inside the same object, but it returns an error that the function doesn't exist.

I still learning JS so, i really don't know how to make this work.

If ideclare all variables and functions as global, it works, but, i wanna make it as a object, so is easyer to work.

Thanks :)

Error like the variables/functions did not exist

The Console:

Command: Baixar = Object.create(Atualizador)
Return: {}
Command: Baixar.AtualizarMangas('nome=tamer')
Return: undefined
Error: atualizador.js:17 Uncaught (in promise) TypeError: this.AtualizarProximoManga is not a function
    at atualizador.js:17:9
(anônimo) @ atualizador.js:17
Promise.then (assíncrono)
AtualizarMangas @ atualizador.js:14
(anônimo) @ VM5443:1


Command: Baixar.AtualizarProximoManga()
Error: atualizador.js:26 Uncaught TypeError: Cannot read properties of undefined (reading 'Nome')
    at Object.AtualizarProximoManga (atualizador.js:26:85)
    at <anonymous>:1:8
AtualizarProximoManga @ atualizador.js:26
(anônimo) @ VM5451:1

The code:

var Atualizador = {
    QtdMaxima: 5,
    Mangas: [],
    Quantidade: 0,
    Atual: -1,
    QtdAtualizando: 0,  
    Concluido: false,           
    AtualizarMangas: function (parametros = '') {
        Query = 'action=listarmangasdb';
        if (parametros != '') {
            Query = Query+'&'+parametros;
        }
        Response = getExternalAPIResponse(Query);
        Response.then(function(result){
            this.Mangas = result;
            this.Quantidade = this.Mangas.length;
            this.AtualizarProximoManga();
        })  
        
        
    },
    
    AtualizarProximoManga: function() {
        this.Atual += 1;
        this.QtdAtualizando += 1;
        getExternalAPIResponse('action=updatemangachapters&manga='+this.Mangas[this.Atual]['Nome']).then(
            function(result) {
                this.QtdAtualizando -= 1;
                this.IniciarProximo();
            }
        )
        this.IniciarProximo();
    },
    
    IniciarProximo: function() {
        if (!this.Concluido) {
            if (this.Atual < this.Quantidade) {
                if (this.QtdAtualizando < this.QtdMaxima) {
                    this.AtualizarProximoManga();
                }   
            } else {
                this.Concluido = true;
                console.log('Mangas Atualizados');
            }
        }
    },
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!