/** * Vue Jsonp. * # Carry Your World # * * @author: LancerComet * @license: MIT */ import { PluginObject } from 'vue/types/plugin'; declare module 'vue/types/vue' { interface Vue { $jsonp: typeof jsonp; } } /** * JSONP Vue plugin. * * @example * Vue.use(VueJsonp) */ declare const VueJsonp: PluginObject; /** * Make a json request. * * @template T * @param {string} url Target URL address. * @param {IJsonpParam} [param={}] Querying params object. * @param {number} [timeout] Timeout setting (ms). * @returns {Promise} * * @example * const data = await jsonp('/url', { * type: 'admin', * date: '2020' * }) */ declare function jsonp(url: string, param?: IJsonpParam, timeout?: number): Promise; declare function jsonp(url: string, param?: IJsonpParam, config?: IConfig): Promise; export { VueJsonp, jsonp }; /** * JSONP parameter declaration. */ interface IJsonpParam { /** * Callback query name. * This param is used to define the query name of the callback function. * * @example * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice" * const result = await jsonp('/some-url', { * callbackQuery: 'myCallback', * callbackName: 'jsonp_func', * myCustomUrlParam: 'veryNice' * }) * * @default callback */ callbackQuery?: string; /** * Callback function name. * This param is used to define the jsonp function name. * * @example * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice" * const result = await jsonp('/some-url', { * callbackQuery: 'myCallback', * callbackName: 'jsonp_func', * myCustomUrlParam: 'veryNice' * }) * * @default jsonp_ + randomStr() */ callbackName?: string; /** * Custom data. */ [key: string]: any; } /** * JSONP Config. */ interface IConfig { /** * Request timeout, ms. * * @default 5000 */ timeout?: number; /** * This is the indicator that used in query string to indicate arrays. * * @example * // When you pass a '[]' or nothing: * a[]=1&a[]=2&a[]=3 // This form is used widely. * * // An empty sring was passed: * a=1&a=2&a=3 // This is a custom example. * * @default '[]' */ arrayIndicator?: string; }