Skip to main content
deleted 2 characters in body
Source Link
Oleksandr
  • 9.8k
  • 1
  • 22
  • 45

According to https://github.com/axios/axios#axiosposturl-data-config axios.post has following signature

axios.post(url[, data[, config]]) 

So you just need to change your request to

export const SaveWeek = weekData => { //headers should be simple object, not Headers const headers = { "Content-Type": "application/json" }; //removed body, because we pass data as second parameter //removed method, because 'axios.post' implies using "post" method const Config = { headers, mode: "cors" }; const url = "http://localhost:52350/api/REST/AddHour"; return axios.post(url, weekData, { Week }Config); } 

According to https://github.com/axios/axios#axiosposturl-data-config axios.post has following signature

axios.post(url[, data[, config]]) 

So you just need to change your request to

export const SaveWeek = weekData => { //headers should be simple object, not Headers const headers = { "Content-Type": "application/json" }; //removed body, because we pass data as second parameter //removed method, because 'axios.post' implies using "post" method const Config = { headers, mode: "cors" }; const url = "http://localhost:52350/api/REST/AddHour"; return axios.post(url, weekData, { Week }); } 

According to https://github.com/axios/axios#axiosposturl-data-config axios.post has following signature

axios.post(url[, data[, config]]) 

So you just need to change your request to

export const SaveWeek = weekData => { //headers should be simple object, not Headers const headers = { "Content-Type": "application/json" }; //removed body, because we pass data as second parameter //removed method, because 'axios.post' implies using "post" method const Config = { headers, mode: "cors" }; const url = "http://localhost:52350/api/REST/AddHour"; return axios.post(url, weekData, Config); } 
added 361 characters in body
Source Link
Oleksandr
  • 9.8k
  • 1
  • 22
  • 45

According to https://github.com/axios/axios#axiosposturl-data-config axios.post has following signature

axios.post(url[, data[, config]]) 

So you just need to change your request to

export const SaveWeek = weekData => { //headers should be simple object, not Headers const headers = { "Content-Type": "application/json" }; //removed body, because we pass data as second parameter //removed method, because 'axios.post' implies using "post" method const Config = {   headers,   mode: "cors"  };  const url = "http://localhost:52350/api/REST/AddHour";  return axios.post(url, weekData, { Week }); } 

According to https://github.com/axios/axios#axiosposturl-data-config axios.post has following signature

axios.post(url[, data[, config]]) 

So you just need to change your request to

const Config = { headers, mode: "cors" }; const url = "http://localhost:52350/api/REST/AddHour"; return axios.post(url, weekData, { Week }); 

According to https://github.com/axios/axios#axiosposturl-data-config axios.post has following signature

axios.post(url[, data[, config]]) 

So you just need to change your request to

export const SaveWeek = weekData => { //headers should be simple object, not Headers const headers = { "Content-Type": "application/json" }; //removed body, because we pass data as second parameter //removed method, because 'axios.post' implies using "post" method const Config = {   headers,   mode: "cors"  };  const url = "http://localhost:52350/api/REST/AddHour";  return axios.post(url, weekData, { Week }); } 
Source Link
Oleksandr
  • 9.8k
  • 1
  • 22
  • 45

According to https://github.com/axios/axios#axiosposturl-data-config axios.post has following signature

axios.post(url[, data[, config]]) 

So you just need to change your request to

const Config = { headers, mode: "cors" }; const url = "http://localhost:52350/api/REST/AddHour"; return axios.post(url, weekData, { Week });