I don't have access to an external API but I am being blocked out by CORS. I have also enabled "Access-Control-Allow-Origin" in the Axios post config. Most answers are tailored to a local api. How do I get around this?
const auth = {
username: "xxx",
password: "xxx",
};
const res = await axios.get(
`https://api.staging.CORP.dev/stuff/{my-key}/pub_id`,
{ auth },
{
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
}
);
const pub = res.data.map((pub) => ({ puv_id: pub.id }));
const data = {
address: {
postcode: 'PostCode',
},
full_name: 'name',
email: 'email',
pub_id: pub
};
axios
.post(
"https://api.staging.CORP.dev/stuff/{public}/orders",
data,
{ auth },
{
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*",
},
}
)
.then((res) => console.log(res))
.catch((err) => console.log(err.response));