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

245
Views
Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Invalid name
const handleAddProduct = (e) => {
    e.preventDefault()

    const product_name = e.target.name.value;
    const image = e.target.image.value;
    const description = e.target.description.value;
    const price = e.target.price.value;
    const quantity = e.target.quantity.value;
    const supplyar_name = e.target.supplier_name.value;
    const card = {
      product_name,
      image,
      description,
      price,
      quantity,
      supplyar_name,
    };
    console.log(card);
    fetch("https://enigmatic-eyrie-33917.herokuapp.com/product", {
      method: "POST",
      headers: {
        "content/type": "application/json",
      },
      body: JSON.stringify(card),
    })
      .then((res) => res.json())
      .then((data) => {
        console.log(data);
      });
    e.target.reset();
};

whats wroon this code

error:

Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Invalid name

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

0

You have made mistake in this line

"content/type": "application/json"

"content-type": "application/json"

It should be like this,

fetch("https://enigmatic-eyrie-33917.herokuapp.com/product", {
  method: "POST",
  headers: {
    "content-type": "application/json",
  },
  body: JSON.stringify(card),
})

official document here

I hope you clear with this.

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!