Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import axios from 'axios'
import qs from 'qs';
import store from '../store/'
import router from '../router/'
// axios ้
็ฝฎ
axios.defaults.timeout = 10000;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8;multipart/form-data;boundary=----WebKitFormBoundaryeOOd9EoQVo6B4Tgb';
// /api่ฟไธชไฝ็ฝฎๅจconfig/index.js้้ข่ฎพ็ฝฎไบไปฃ็๏ผๆๅ localhost:8081/api่ฟไธชๅๅฐๅฐๅ
axios.defaults.baseURL = 'http://localhost:8081/api';
// http request ๆฆๆชๅจ
axios.interceptors.request.use(
config => {
if (store.state.token) { // ๅคๆญๆฏๅฆๅญๅจtoken๏ผๅฆๆๅญๅจ็่ฏ๏ผๅๆฏไธชhttp header้ฝๅ ไธtoken
config.headers.Authorization = `Bearer ${store.state.token}`;
}
console.log(config);
return config;
},
err => {
return Promise.reject(err);
});
import React from 'react'
import PropTypes from 'prop-types'
import axios from 'axios'
// import RMathJax from 'react-mathjax' // alias as RMathJax instead global MathJax
import MediaQuery from 'react-responsive'
import {Prompt} from 'react-router-dom'
import Draggable from 'react-draggable'
import {ScoreBoard} from './score_board'
import {GameState} from '../constants'
var math = require('mathjs')
var Qty = require('js-quantities')
axios.defaults.xsrfHeaderName = 'X-CSRFToken'
axios.defaults.xsrfCookieName = 'csrftoken'
class UNITS {
static get DISTANCE () {
return {
'mm': 'millimeters',
'cm': 'centimeters',
'km': 'kilometers',
'ft': 'feet',
'mi': 'miles'
}
}
static get TIME () {
return {
'ms': 'milliseconds',
import Vue from 'vue'
import router from '../router'
import axios from 'axios'
import { Indicator } from 'mint-ui';
import { Toast } from 'mint-ui';
axios.defaults.timeout = 30000;
axios.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8'
// http request ๆฆๆชๅจ
axios.interceptors.request.use(
config => {
Indicator.open({
text: 'ๅ ่ฝฝไธญ...',
spinnerType: 'fading-circle'
});
return config;
},
err => {
Indicator.close();
Toast({
message: 'ๅ ่ฝฝ่ถ
ๆถ',
position: 'middle',
duration: 3000
import * as axios from 'axios';
import Constant from './../utilities/constants';
axios.defaults.baseURL = Constant.api_base_url;;
axios.defaults.headers.post['Content-Type'] = 'application/json';
// Axios interceptor for handling common HTTP errors
// Need to use it with reducers
axios.interceptors.response.use(res => res, err => Promise.reject(error));
/**
* HTTP request to search item in The MovieDB
*
* @returns {object | Promise}
*/
const getConfiguration = () => {
return axios.get(`/configuration?${Constant.api_key}`)
}
export { getConfiguration }
const axios = require('axios');
const _ = require('underscore');
const colornamer = require('color-namer');
axios.defaults.baseURL = 'http://www.colourlovers.com/api/palettes';
axios.defaults.params = { format: 'json' };
const _formatColors = colors => {
return colors.map(color => `#${color}`);
};
const _flattenResponse = data => {
return data.reduce((a, b) => a.concat(b.colors), data[0].colors);
};
const _removeShownColors = ({ newColors, dislikedColors, likedColors }) => {
// Remove all colors that have been disliked or are already liked
return newColors.filter(
color =>
dislikedColors.indexOf(`#${color}`) === -1 &&
likedColors.indexOf(`#${color}`) === -1
clearToken() {
// Remove the HTTP header that include the session token
delete axios.defaults.headers.common['Authorization'];
// Delete the token from our session
sessionStorage.removeItem('token');
this.token = null;
},
// Log out the user
beforeEach(() => {
axios.defaults.adapter = require('axios/lib/adapters/http');
});
async function impersonate(userId, password) {
const token = await authenticate(axios, userId, password);
console.log(`Now logged in as ${userId}`);
axios.defaults.headers.common.Authorization = `Bearer ${token}`;
}
import React from 'react';
import axios from 'axios';
import Modal from 'react-responsive-modal';
import CheckboxWithLabel from 'p2pu-input-fields/dist/CheckboxWithLabel'
import InputWithLabel from 'p2pu-input-fields/dist/InputWithLabel'
import { API_ENDPOINTS } from '../../helpers/constants'
import '../stylesheets/learning-circle-form.scss';
import 'p2pu-input-fields/dist/build.css';
axios.defaults.xsrfCookieName = 'csrftoken'
axios.defaults.xsrfHeaderName = 'X-CSRFToken'
export default class RegistrationModal extends React.Component {
constructor(props) {
super(props);
this.state = { user: this.props.user || { communication_opt_in: true }, errors: {}, registration: true };
this.updateUserData = (data) => this._updateUserData(data);
this.toggleModalType = () => this._toggleModalType();
this.submitForm = (e) => this._submitForm(e);
}
_updateUserData(data) {
this.setState({
user: {
...this.state.user,
}
return false;
}
let root;
if (isDevEnv()) {
root = 'http://120.27.216.199:9080';
} else {
root = `http://${location.host}`
}
/**
* ๆบๅธฆcookie
**/
axios.defaults.withCredentials = true;
axios.interceptors.response.use(
function (response) {
indicator.hideBusy()
if (response.data.code == 200) {
return response;
}
if (response.data.code == 801 ||
response.data.code == 802 ||
response.data.code == 804
) {
router.push({name: USER_LOGIN})
return Promise.reject(response.data.result);
}