C:\Users\Pedro\Desktop\aluranodesql\models\atendimentos.js:69
const { data } = await axios.get(http://localhost:8082/${cpf}
)
^^^^^
SyntaxError: await is only valid in async function at wrapSafe (internal/modules/cjs/loader.js:1053:16) at Module.compile (internal/modules/cjs/loader.js:1101:27) at Object.Module.extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module.load (internal/modules/cjs/loader.js:878:14) at Module.require (internal/modules/cjs/loader.js:1025:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\Pedro\Desktop\aluranodesql\infraestrutura\tabelas.js:1:22) at Module.compile (internal/modules/cjs/loader.js:1137:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) [nodemon] app crashed - waiting for file changes before starting...
BuscaPorId(id, res){
const sql = `SELECT * FROM atendimentos WHERE id=${id}`
conexao.query(sql, (erro,resultados) =>{
const atendimento = resultados[0]
const cpf = atendimento.cliente
if(erro){
res.status(400).json(erro)
}
else{
const { data } = await axios.get(`http://localhost:8082/${cpf}`)
atendimento.cliente = data
res.status(200).json(atendimento)
}
})
}
aparece esse erro do await ou um erro que fala do axios