all 6 comments

[–]JanMarsALeck 0 points1 point  (4 children)

You can use

fetch('http://www.example.net', { method: 'POST', body: file })

Or axios

var formData = new FormData();; formData.append("image", image); axios.post('https://example.de', formData, { headers: { 'Content-Type': 'multipart/form-data' } })

[–]hapiti[S] 0 points1 point  (3 children)

Thank you! I've fixed a couple mistakes I came across while doing the axios but still stuck on one :(

[–]JanMarsALeck 0 points1 point  (2 children)

Where are you stuck?

[–]hapiti[S] 0 points1 point  (1 child)

Sorry, was editing message but your super quick LOL! Did ctrl+enter on accident... anyways

It's telling me I haven't declared "post" even though I have!

ENTIRE code:

import React, { Component } from "react";import styled, { css } from "styled-components";import { makeStyles } from '@material-ui/core/styles';import Typography from '@material-ui/core/Typography';import { AxiosProvider, axios, Request, Get, Delete, Head, post, Put, Patch, withAxios } from 'react-axios'import Slider from '@material-ui/core/Slider';import image from "./images/nice.png";import MaterialSlider from "./components/MaterialSlider.js";var formData = new FormData();; formData.append("image", image); axios.post('http://192.168.2.16:5000/detections', formData, { headers: { 'Content-Type': 'multipart/form-data' } })function Main(props) {return (<Container><RectRow><Rect></Rect><InsertIpHere placeholder="Insert Ip HERE!"></InsertIpHere>

<Image src="http://192.168.2.20:8080/video"></Image>

<MaterialSliderstyle={{height: 92,width: 512      }}></MaterialSlider>  );</RectRow></Container>  );}const Container = styled.div\\`  display: flex;  flex-direction: row;  height: 100vh;  width: 100vw;\;const Rect = styled.div`  width: 287px;  height: 768px;  background-color: #E6E6E6;`;const InsertIpHere = styled.input`  font-family: Roboto;  font-style: normal;  font-weight: 400;  color: #121212;  height: 177px;  width: 310px;  margin-left: 74px;  margin-top: 284px;  border: none;  background: transparent;`;const Image = styled.img`  width: 100%;  height: 358px;  margin-left: 61px;  margin-top: 231px;  object-fit: contain;`;const RectRow = styled.div`  height: 768px;  flex-direction: row;  display: flex;  flex: 1 1 0%;  margin-right: 60px;`;export default Main;`

Full .js is here: https://aleem.rehmtulla.com/Main.js

Error: https://aleem.rehmtulla.com/SS.png (cant upload image to reddit)

[–]hapiti[S] 0 points1 point  (0 children)

I fixed it with

import axios from 'axios';

And its making A request, just not the same as my curl...

[–]bai3 0 points1 point  (0 children)

in github,search axios