Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 unauthorized on bad request #260

Open
impactcolor opened this issue Sep 20, 2023 · 0 comments
Open

401 unauthorized on bad request #260

impactcolor opened this issue Sep 20, 2023 · 0 comments

Comments

@impactcolor
Copy link

I'm following the documentation found here

I'm attemping to add a category based on the docs. Here is my attempt:
`import 'dotenv/config';
import axios from 'axios';

const url = new URL(
"https://api.chec.io/v1/categories"
);

const headers = {
"X-Authorization": ${process.env.COMMERCE_SECRET},
"Content-Type": "application/json",
"Accept": "application/json",
};

function postDetails() {
const body = {
slug: 'test slug',
name: 'testCat'
}

axios.post(url, JSON.stringify(body), headers)
.then(response => {
    console.log(response);
})
.catch(err => {
    console.error(err);
})

}

postDetails();`

I get the a 401 on my response
I'm executing this from a local node js file. I added http://localhost to the Cross-Origin Resource Sharing (CORS) origins on the dashboard. I've also tried both my secret and public key types. Any idea what I'm doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant