“reação de solicitação de postagem” Respostas de código

reação de solicitação de postagem

componentDidMount() {
    // Simple POST request with a JSON body using fetch
    const requestOptions = {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ title: 'React POST Request Example' })
    };
    fetch('https://jsonplaceholder.typicode.com/posts', requestOptions)
        .then(response => response.json())
        .then(data => this.setState({ postId: data.id }));
}
Fair Fly

Como enviar uma solicitação de postagem com o React

  const handler = () => {
        const requestOptions = {
          mode: 'no-cors' as RequestMode,
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ "logo": "t-shirt" })
          };
          fetch('http://localhost:8080/tshirt/19', requestOptions)
              .then(response => response.json())
              .then(data => setApiData({ postId: data.id }));
        }
Daniel Kristoffersen

Respostas semelhantes a “reação de solicitação de postagem”

Perguntas semelhantes a “reação de solicitação de postagem”

Mais respostas relacionadas para “reação de solicitação de postagem” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código