I'm getting an error when I make an API call using axios
to create an API key. This is the second call. Before this call, I'm making another one to get a JWT. That call goes through without a problem and I'm able to receive the token. The problem occurs when I use the result/token from this call to create the API key
This is the error:
error: "Request failed with status code 401"
This is my code:
const createFpAPIKey = async (token) => {
const raw = { name: "any name", type: "api" };
const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
};
const url = "https://sandbox.fluidpay.com/api/user/apikey";
let r = {};
try {
r = await axios({
method: "post",
url,
data: raw,
headers,
withCredentials: true,
});
r = r.data;
if (typeof r.body === "string") r = JSON.parse(r.body);
} catch (e) {
r = {
errorType: "Error Fetching API",
error: e.message,
};
}
return r;
},