chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.module.rule('vue').uses.delete('cache-loader');
config.module.rule('js').uses.delete('cache-loader');
config.module.rule('ts').uses.delete('cache-loader');
config.module.rule('tsx').uses.delete('cache-loader');
}
}
if (typeof(json.dialog) == 'object') {
const _dialog = json.dialog.reduce((acc,cur,i,a)=>{
const index = acc.findIndex(item => item.date === cur.date)
if( index !== -1 ){
acc[index].message.push({text: cur.text, time: cur.time})
}else{
cur.message = []
cur.message.push({text: cur.text, time: cur.time})
acc.push(cur)
}
return acc
},[])
$('div.dialog').html(_dialog.map(item => {
let div = `<div>${item.date}</div>`
item.message.forEach(_item => {
div += `<div><span name="text">${_item.text}</span><span name="time">${_item.time}</span></div>`
})
return div;
}).join(''));
}
Есть ли способ решить проблему не прибегая к импорту axios напрямую?
import axios from 'axios'
window.axios = axios;
const { token } = await axios.post('http://localhost:3000/login', formData);
const autoprefixer = require('gulp-autoprefixer');
function scssTask(){
return src(files.scssPath)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer())
.pipe(sourcemaps.write('.'))
.pipe(dest('public/css')
);
}
"main": "gulpfile.js",
"browserslist": [
"last 2 version",
"> 1%",
"maintained node versions",
"not dead"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
let $start = document.querySelector('#start')
// Прослушки
$start.addEventListener('click', startAdd)
// Функция
function startAdd() {
let i = 0;
let all = 0;
// Ваш токен
$token = 'token';
// Фильтр
$filter = 'mutual';
// Поля
$fields = 'online,sex,common_count';
// Получаем массив с ID пользователей
$.ajax({
url: 'https://api.vk.com/method/friends.getSuggestions?f...' + $filter + '&fields=' + $fields + '&count=500&access_token=' + $token + '&v=5.103',
type: 'GET',
dataType: 'jsonp',
crossDomain: true,
success: function(data) {
const _data = data.response.items
secondAjax()
}
})
}
function secondAjax(){
if(i => _data.length) return
$.ajax({
url: 'https://api.vk.com/method/friends.add?user_id=' + _data[i].id + '&v=5.69&access_token=' + $token,
type: 'POST',
dataType: 'jsonp',
crossDomain: true,
success: function(data) {
document.body.innerHTML = "Добавленно: " + i + " из " + _data.length
console.log(data)
i++
setTimeout(()=>{
secondAjax()
},60000 * 2)
}
})
}
document.querySelector('select[name=email]').addEventListener('change',(e)=>{
const v = e.currentTarget.value
document.querySelector('input[name=admin_email]').value = v
},false)
$('select[name=email]').change(function(){
const v = $(this).val()
$('input[name=admin_email]').val(v)
});
const data = Object.keys(this.elements).reduce((res, key)=>{
if(this.elements[key]) res[key] = this.elements[key].value;
return res;
}, {});
let data = {}
for(let i in this.elements){
if( this.elements.hasOwnProperty(i)){
if( this.elements[i] ){
data[i] = this.elements[i].value
}
}
}
public function update(Request $request, Post $post, $id)
{
$request->validate([
// rules
]);
// действия с БД
return response()->json([
'status' => true,
'message' => 'данные изменены'
]);
}