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

115
Visualizações
POST request on form submit ember.js

I am totally green in Ember.JS. I’ve made simple adoption shelter application with Ember tutorials as I am using ember on front end, and Strapi (Node.JS) as an Headless CMS. I have all the endpoints and my ember front is successfully fetching data with GET method via JavaScript’s fetch. However, I want to allow users to create POST requests based on form submit, I can’t find any good example or tutorial how to properly make an post request on form submit in ember.js, could you please help me with figuring out how to do this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Using:

  • https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
  • https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
  • https://developer.mozilla.org/en-US/docs/Web/API/FormData
  • https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/formdata_event
  • https://developer.mozilla.org/en-US/docs/Web/API/SubmitEvent
  • https://guides.emberjs.com/release/components/template-lifecycle-dom-and-modifiers/#toc_event-handlers

I think you could submit a form via:

ember g component my-form -gc

And then in that component

// app/components/my-form.js
import Component from '@glimmer/component';

export default class MyForm extends Component {

  submit = async (event) => {
    event.preventDefault();

    let data = new FormData(event.target);

    await fetch('your url', {
      method: 'POST',
      body: JSON.stringify(data),
    });

  }
}
{{! app/components/my-form.hbs }}
<form {{on 'click' this.submit}}>
  ...
</form>
about 4 years ago · Juan Pablo Isaza 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