Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to send a post request with 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 }));
        }
Source by jasonwatmore.com #
 
PREVIOUS NEXT
Tagged: #send #post #request #react
ADD COMMENT
Topic
Name
7+6 =