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

Receiving following error message "AxiosError: Request failed with status code 401" on request #31342

Closed
jcrans13 opened this issue Jun 17, 2024 · 1 comment

Comments

@jcrans13
Copy link

jcrans13 commented Jun 17, 2024

I am using playwright with JavaScript/Typescript
version: 10.8.1

I have 2 methods, 1 in which I am getting the auth token in order to make the next api call
I think I have the syntax wrong somewhere but I have no idea where. I am doing pretty much what I am doing in the previous api call except I am importing parts of an api array (which works fine in other api calls).

`let apiURL = process.env.API_URL;
let token: any;

async get_token(): Promise {
axios({
method: 'post',
url: apiURL + apis.authenticate,
data: {
username: 'string',
password: 'string',
apiKey: 'string'
}
}).then(async function (response) {
token = response.data.token;
expect(response.status).toBe(200);
});
}

async cancel_appointment(): Promise {
axios({
method: 'put',
url: apiURL + apis.cancel[0] + accountNumber + apis.cancel[1] + appointmentNumber + apis.cancel[2],
headers: {
'Authorization': Bearer ${token}
}
}).then(async function (response) {
console.log(response.data);
console.log(response.status);
console.log(response.statusText);
console.log(response.headers);
console.log(response.config);
expect(response.status).toBe(200);
});
}`

Error: AxiosError: Request failed with status code 401

Any help would be greatly appreciated!!

@dgozman
Copy link
Contributor

dgozman commented Jun 17, 2024

This issue tracker is reserved for bug reports and feature requests.

For anything else, such as questions or getting help, please see:

@dgozman dgozman closed this as completed Jun 17, 2024
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

2 participants