Giter VIP home page Giter VIP logo

Comments (5)

MatheusDeAquino avatar MatheusDeAquino commented on June 25, 2024 1

Consegui reproduzir seu erro aqui. Tem relação com o uso do async await.
Você está tentando trabalhar dados que ainda não chegaram do servidor.

async function robot(content) {
    await fetchContentFromWikipedia(content)
    ...
    async function fetchContentFromWikipedia(content) {
    ...

Eu tentei mexer no async/await de varias formas e o erro persiste.
Neste momento do code o @filipedeschamps conseguiu baixar do wikipedia com letra verde e tal. Meu caso fica esse erro :(

Meu "text.js" está assim:

const algorithmia = require('algorithmia') //importando o modulo deles pro bot
const algorithmiaApiKey = require('../credentials/algorithmia.json').apiKey

async function robot(content){
    await BuscaWikipedia(content)
    //LimparConteudo(content)
    //QuebrarSentencas(content)

    async function BuscaWikipedia(content) {
        const algorithmiaAutenticada = algorithmia(algorithmiaApiKey)
        const wikipediaAlgorithm = algorithmiaAutenticada.algo('web/WikipediaParser/0.1.2') //link no site deles. Aba node JS
        const wikipediaResponde = await wikipediaAlgorithm.pipe(content.serarchTerm)
        const wikipediaContent = wikipediaResponde.get()   
        console.log(wikipediaContent)
    }
}
module.exports = robot

:::
Meu "index.js" está assim:

const readline = require('readline-sync')
const robots = {
	text: require('./robots/text.js')
}

function start() {
	const content = {}

	content.searchTerm = askAndReturnSearchTerm()
	content.prefix = askAndReturnPrefix()

	robots.text(content)

	function askAndReturnSearchTerm() {
		return readline.question('Digite um termo de pesquisa da Wikipedia: ')
	}
	function askAndReturnPrefix() {
		const prefixes = ['Quem e', 'O que e', 'A historia de']
		const selectedPrefixIndex = readline.keyInSelect(prefixes, 'Escolha uma alternativa: ')
		const selectedPrefixText = prefixes[selectedPrefixIndex]

		return selectedPrefixText
	}

	console.log(content)
}
start()

:::

CONSEGUI!

o ERRO ERA QUE EU ESCREVI "searchTerm" errado na linha de comando.
"const wikipediaResponde = await wikipediaAlgorithm.pipe(content.serarchTerm)"

Isso que da programar sem parar. Não queria dormir com erro no code mas agora de manhã ja acordei revendo isso.
Obrigado pelo ajuda a todos aí!

from video-maker.

hugocalheira avatar hugocalheira commented on June 25, 2024

Consegui reproduzir seu erro aqui. Tem relação com o uso do async await.
Você está tentando trabalhar dados que ainda não chegaram do servidor.

async function robot(content) {
    await fetchContentFromWikipedia(content)
    ...
    async function fetchContentFromWikipedia(content) {
    ...

from video-maker.

Vinicius-CS avatar Vinicius-CS commented on June 25, 2024

@MatheusDeAquino também estou com esse problema, @hugocalheira sabe como resolver?

from video-maker.

MatheusDeAquino avatar MatheusDeAquino commented on June 25, 2024

Consegui reproduzir seu erro aqui. Tem relação com o uso do async await.
Você está tentando trabalhar dados que ainda não chegaram do servidor.

async function robot(content) {
    await fetchContentFromWikipedia(content)
    ...
    async function fetchContentFromWikipedia(content) {
    ...

Eu tentei mexer no async/await de varias formas e o erro persiste.
Neste momento do code o @filipedeschamps conseguiu baixar do wikipedia com letra verde e tal. Meu caso fica esse erro :(

Meu "text.js" está assim:

const algorithmia = require('algorithmia') //importando o modulo deles pro bot
const algorithmiaApiKey = require('../credentials/algorithmia.json').apiKey

async function robot(content){
    await BuscaWikipedia(content)
    //LimparConteudo(content)
    //QuebrarSentencas(content)

    async function BuscaWikipedia(content) {
        const algorithmiaAutenticada = algorithmia(algorithmiaApiKey)
        const wikipediaAlgorithm = algorithmiaAutenticada.algo('web/WikipediaParser/0.1.2') //link no site deles. Aba node JS
        const wikipediaResponde = await wikipediaAlgorithm.pipe(content.serarchTerm)
        const wikipediaContent = wikipediaResponde.get()   
        console.log(wikipediaContent)
    }
}
module.exports = robot

:::
Meu "index.js" está assim:

const readline = require('readline-sync')
const robots = {
	text: require('./robots/text.js')
}

function start() {
	const content = {}

	content.searchTerm = askAndReturnSearchTerm()
	content.prefix = askAndReturnPrefix()

	robots.text(content)

	function askAndReturnSearchTerm() {
		return readline.question('Digite um termo de pesquisa da Wikipedia: ')
	}
	function askAndReturnPrefix() {
		const prefixes = ['Quem e', 'O que e', 'A historia de']
		const selectedPrefixIndex = readline.keyInSelect(prefixes, 'Escolha uma alternativa: ')
		const selectedPrefixText = prefixes[selectedPrefixIndex]

		return selectedPrefixText
	}

	console.log(content)
}
start()

:::

from video-maker.

danielschmitz avatar danielschmitz commented on June 25, 2024

Erro resolvido, fechando a issue.

from video-maker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.