You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
748 B
JavaScript
29 lines
748 B
JavaScript
// Copyright (C) 2019-2021 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
const Axios = require('axios');
|
|
|
|
Axios.defaults.withCredentials = true;
|
|
Axios.defaults.xsrfHeaderName = 'X-CSRFTOKEN';
|
|
Axios.defaults.xsrfCookieName = 'csrftoken';
|
|
|
|
onmessage = (e) => {
|
|
Axios.get(e.data.url, e.data.config)
|
|
.then((response) => {
|
|
postMessage({
|
|
responseData: response.data,
|
|
id: e.data.id,
|
|
isSuccess: true,
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
postMessage({
|
|
id: e.data.id,
|
|
status: error.response.status,
|
|
responseData: error.response.data,
|
|
isSuccess: false,
|
|
});
|
|
});
|
|
};
|