Esse replic está me deixando confuso

Tell us what’s happening:
Describe your issue in detail here.

Your project link(s)

solution: https://replit.com/@lindomarquintao/boilerplate-express-4

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 8.0.0; ASUS_Z012DC) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Mobile Safari/537.36

Challenge: Implement a Root-Level Request Logger Middleware

Link to the challenge:

Esse é mais tranquilo, @lindomaraqo .
A dica fala em usar:
app.use(function middleware(req, res, next) {
// Do something
// Call the next function in line:
next();
});

Logo abaixo, diz que, para criar uma string que use o método (GET, POST) o caminho (path) e o endereço ip, é preciso usar a sintaxe:
var string = req.method + " " + req.path + " - " + req.ip;

Então, dentro da função middleware, substitua os comentários por uma variável com o nome, por exemplo, de “register” e envie-a para o console (instrução do desafio), dessa forma:
app.use(function middleware(req, res, next) {
var register = req.method + " " + req.path + " - " + req.ip;
console.log(register);
next();
});

Mande o endereço do seu boilerplate para a solução e teste. Abraço.

Devo está fazendo erradom ou o replic?


Para esse aqui, você remove todo o app.get. Deixa só o app.use. Não esquece de parar o servidor e mandar rodar de novo.

Fi isso não dá certo

image

Não dá certo. O replic até faz a coisa certa. Mas na hora de colar o endereço da erro

Mas no seu https://boilerplate-express-16.beatrizgames.repl.co/ ainda está com o app.get.


Retire toda essa parte que eu circulei em vermelho, mande rodar de novo e daí teste.

Ainda não deu certo. O q estou errando?

“O middleware do logger de nível raiz deve está ativo”. Aparece essa mensagem

@lindomaraqo again, please stop posting pictures of code. You’re making it harder for people to help you. It is difficult to read screenshots of code, especially low quality screenshots of code. Please provide the link to your repl when asking for help so that it is easier for more people to help you. The code you linked and your pictures are very different.

From the picture it looks like you need to check the value of the secret inside the function instead of outside. This lets your code respond to changes in the environment.

1 Like

Esse que está em vermelho está a mensagem: " A resposta do Endpoint
/json deve mudar de acordo com a variável de ambiente MESSAGE_STYLE.

That’s because you’re only checking the message style secret once in the global scope. You need to check the message style inside of the function for the API call instead so that your code can correctly handle changes to the secret.

Desculpe não entendo sou novo na programação…

Now I’m starting to get confused. Which challenge are you doing? The screenshot you made and the challenge you linked are different.

It really helps to have the current link to your current code so others can debug effectively.

Desculpa vomu tentar ser claro. Realmente meu celular napi ajuda . Viu entrar no Desktop. tankYou.

Seu boilerplate no repl para mim aparece assim:

Ou seja, você está usando a resposta que está na dica como ela está.

Você está usando o boilerplate-express-16 para dois desafios ao mesmo tempo? O link para o repl que está ali em cima aponta para o boilerplate-express-4, enquanto as imagens apontam para o boilerplate-express-16.

Sugiro para essa tarefa você usar o boilerplate-express-4, que está mais vazio. Retire a parte da function que aparece ali e substitua por aquele app.use da 16. Isso resolve a lição do middleware.

Se o problema é a lição onde você precisa colocar o app.get, aí tem três questões: inserir o secret e corrigir a palavra ‘message’, que está escrita incorretamente como ‘messege’ e remover o app.use, que não faz parte do desafio.

Depois foi editado… Vou tentar denovo . Fui tentando resolver os outros exercícios propostos na frente.

Oi Daniel estou preso em alguns exercícios. Não consigo resolver …

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.