This topic was automatically generated from Slack. You can find the original thread here.
Hi All, In my testing today I was trying to get axios to return a status code. I realised that once you add the props for a manages oAuth client, it stops axios from returning the status code.
Heres the example Slack
Here is my test case, and it returns only the body, not the status code as well.
Is this by design, and how can I get the status code?
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
toggl: {
type: "app",
app: "toggl",
},
},
async run({ steps, $ }) {
const togglCreate = await axios($, {
url: `https://api.track.toggl.com/api/v9/workspaces/7498936/projects`,
auth: {
username: `${this.toggl.$auth.api_token}`,
password: `api_token`,
},
method: "POST",
data: { "name": "stuff"},
validateStatus: () => true, // This prevents axios from throwing an error for 400+ status codes
})
console.log(togglCreate); // This should log the status code
if (togglCreate.status >= 400) {
throw new Error(`Error: ${togglCreate.status}`);
}
return togglCreate;
},
});