Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

320
Views
415 Unsupported Media Type in reactjs

I doing delete function to delete banner image. I have create a delete function as below:

    const [del, setDel] = useState([]);

    const DeleteBanner = async (banner) => {
        setDel(banner);
        console.log(del);
        Axios.delete(`/shop/${shopID}/banners`, del)
          .then((res) => {
            if (res.status === 200) {
              setMessage({
                data: `${res.data.MESSAGE}`,
                type: "alert-success",
              });
              onShowAlert();
            }
          })
          .catch((err) => {
            setMessage({
              data: err.response.data.MESSAGE,
              type: "alert-danger",
            });
            setLoading(false);
            onShowAlert();
          });
      };
return (
<div className="">
                {shopData.data.ShopBanner.map((banners) => (
                  <Col
                    md="6"
                    xs="12"
                    className="p-0 m-0"
                    key={`img-${banners}`}
                    href="#pimage"
                  
                  >
                    <img
                      className="border border-white"
                      key={`img-${banners}`}
                      src={`/api/v2/public/Shop/${shopID}/banner/${encodeURIComponent(
                        banners
                      )}`}
                      style={{ padding: "5px" }}
                      width="100%"
                      height="100%"
                      alt="banner"
                    />
                    <Button
                      className="btn-link"
                      value={banners}
                      onClick={(e) => {
                        DeleteBanner(e.target.value);
                      }}
                    >
                      Delete
                    </Button>
                  </Col>
                ))}
              </div>
)

then I display the banner image from the database and add a delete button set the value to banners (which is the image id )

the pic from swagger enter image description here

when I try to delete, I'm getting the error 415 Unsupported Media Type, I'm not sure what went wrong. The post method for post the banner image is in fromdata which I success to post but has problem in delete

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Axios accepts two parameters: url and optional config. You can use config.data to set the response body as follows:
Refer : https://github.com/axios/axios/issues/897

axios.delete(URL, {
  headers: {
    'Accept': 'application/json'
  },
  data: del
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!