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

129
Visualizações
Can`t edit api image in CSS

I've requested an image from this recipe api (spoonacular) and I've managed to post the pic on my site, but it's located under my background image. I know how to move and edit images but I can`t link this one in CSS so I can edit it. Here's the .js code and the rest. How do I address the api image in CSS? Many noob thanks!

Tom

import axios from 'axios';
const container = document.getElementById('container')
// const recipeImage = document.getElementById(`image`)

async function fetchImage() {
    try {
        const result = await axios.get('https://api.spoonacular.com/recipes/complexSearch?apiKey=...',{
            headers:{
                "Content-Type": "application/json"
            }})
        const recipe = result.data;
        console.log(recipe.results[5]);
        const image = document.createElement('p')
        const title = document.createElement('h3')

        title.innerHTML =  `<h3>${recipe.results[5].title} </h3>`
        image.innerHTML = `<img src="${recipe.results[5].image}"/>`

        container.appendChild(title)
        container.appendChild(image)

    } catch (e) {
        console.error(e);
    }
}
fetchImage();
.container{
    position: absolute;
    z-index: auto;
    left:43%;
    top: 25%;
    height: 500px;
    width: 645px;
}
<body>
<h1> Jouw selectie voor vandaag . . </h1>
<header>

    <img src="../assets/mood&food%20achtergrond%20licht%20patroon.jpg" height="800" width="1695" class="background"/>
    <a href="index.html">
    <img src="../assets/mood&food logo basic.png" height="80px" width="45%" class="logo"/></a>

    <div id="container">
        <h3></h3>
        <p></p>
    </div>

</header>
</body>
<script type="module" src="app.js"></script>
</html>

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The api key needed to be refreshed. Second time this problem occurred. Now the 'id=container' reference worked and the image was editable.

about 4 years ago · Santiago Trujillo Relatório
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