All Projects → loshafee → jsonp

loshafee / jsonp

Licence: MIT License
a jsonp module using promise

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to jsonp

Cross Origin
🌀 跨域demo。CORS、JSONP、postMessage、websocket、document.domain、window.name、iframe等示例
Stars: ✭ 475 (+3066.67%)
Mutual labels:  jsonp
Restler
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API
Stars: ✭ 1,324 (+8726.67%)
Mutual labels:  jsonp
ljq vue music
vue2 + vue-router2 +vuex + jsonp + es6 +webpack 抓取QQ音乐真实数据的移动端音乐WebApp
Stars: ✭ 43 (+186.67%)
Mutual labels:  jsonp
Fetch Jsonp
Make JSONP request like window.fetch
Stars: ✭ 932 (+6113.33%)
Mutual labels:  jsonp
Jsonp
Java API for JSON Processing (JSON-P)
Stars: ✭ 77 (+413.33%)
Mutual labels:  jsonp
Seniverse Api Demos
心知天气 API 产品使用调用示例
Stars: ✭ 201 (+1240%)
Mutual labels:  jsonp
Reqwest
browser asynchronous http requests
Stars: ✭ 2,918 (+19353.33%)
Mutual labels:  jsonp
AjaxHandler
ASimple PHP Class to help handling Ajax Requests easily
Stars: ✭ 30 (+100%)
Mutual labels:  jsonp
Dbwebapi
(Migrated from CodePlex) DbWebApi is a .Net library that implement an entirely generic Web API (RESTful) for HTTP clients to call database (Oracle & SQL Server) stored procedures or functions in a managed way out-of-the-box without any configuration or coding.
Stars: ✭ 84 (+460%)
Mutual labels:  jsonp
Instagram Proxy Api
CORS compliant API to access Instagram's public data
Stars: ✭ 245 (+1533.33%)
Mutual labels:  jsonp
Bugrequest
Sniffer vulnerabilities in http request (chrome extension)
Stars: ✭ 20 (+33.33%)
Mutual labels:  jsonp
Vue Music
使用vue2.0构建音乐播放器
Stars: ✭ 60 (+300%)
Mutual labels:  jsonp
Json Viewer
It is a Chrome extension for printing JSON and JSONP.
Stars: ✭ 2,585 (+17133.33%)
Mutual labels:  jsonp
Jsonpcallbackvalidator
JSONP callback validator.
Stars: ✭ 595 (+3866.67%)
Mutual labels:  jsonp
miniAjax
🚀A mini Ajax library provides Ajax, jsonp and ready features for simple web applications.
Stars: ✭ 67 (+346.67%)
Mutual labels:  jsonp
Vue Music
Music Player for Vue.js
Stars: ✭ 324 (+2060%)
Mutual labels:  jsonp
Render
Go package for easily rendering JSON, XML, binary data, and HTML templates responses.
Stars: ✭ 1,562 (+10313.33%)
Mutual labels:  jsonp
cantina
🍔 Stupid web application that checks if the food at my university's canteens is good.
Stars: ✭ 30 (+100%)
Mutual labels:  jsonp
leaflet-layerJSON
Build dynamic JSON Layer via Ajax/JSONP with caching
Stars: ✭ 82 (+446.67%)
Mutual labels:  jsonp
Renderer
Simple, lightweight and faster response (JSON, JSONP, XML, YAML, HTML, File) rendering package for Go
Stars: ✭ 220 (+1366.67%)
Mutual labels:  jsonp

jsonp-request

a jsonp module using promise

Installation && Usage

Browser

In a browser, you can use jsonp-request as follows:

<script src='./lib/jsonp.js' charset='utf8'><script>

it also can be a AMD module while using require.js

NodeJS

Install for node.js using npm

npm install jsonp-request

Require module using require

const jsonp = require('jsonp-request)

Example

Performing a jsonp request

// Make a request using Baidu search fetch url https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=github&cb=jsonp

jsonp('https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su', {
    wd: 'github',
    jsonpCallback: 'cb'
}).then((res) => {
    console.log(res)
})

API

jsonp(url, options)

  • url (String) url to fetch
  • options (Object), optional
    • jsonpCallback define the response function name(defaults to callback)

return a promise.

Interceptors

You can intercept requests or response before they are handled by then or catch.

//Add a request interceptor
jsonp.interceptors.request.use((config) => {
    // Do something before request is send
    return config
}, (error) => {
    // Do something with request error
    return Promise.reject(error)
})

//Add a response interceptor
jsonp.interceptors.response.use((response) => {
    // Do something with response data
    return response
}, (error) => {
    // Do something with response error
    return Promise.reject(error)
})

If you may need to remove an interceptor later you can.

var myInterceptor = jsonp.interceptors.request.use(() => {/*...*/})
jsonp.interceptors.request.eject(myInterceptor)

VUE plugin

The plugin for Vue.js provides services for making web requests and handle response using jsonp

const Vue   = require('Vue')
const jsonp = require('jsonp-request')
Vue.prototype.$jsonp = jsonp

Reference

Promise based HTTP client for the browser and node.js axios

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].