rekingzhang / axios-jsonp Goto Github PK
View Code? Open in Web Editor NEW基于axios的jsonp跨域扩展
License: MIT License
基于axios的jsonp跨域扩展
License: MIT License
I have the following Axios Service API:
import axios from 'axios-jsonp-pro'
const api = axios.create({
baseURL: 'http://teste.com/api/',
headers: {'X-Custom-Header': 'foobar'},
});
export default api
When making the call using JSONP:
api.jsonp('issues.json')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.error(error);
});
I have the return ..
Uncaught SyntaxError: Unexpected token '<' issues.json?callback=__jp0&_=1569598044015:1
and doesn't recognize API baseURL
Hey there!
I'd like to report a security issue but cannot find contact instructions on your repository.
If not a hassle, might you kindly add a SECURITY.md
file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.
Thank you for your consideration, and I look forward to hearing from you!
(cc @huntr-helper)
please give me answer
We use axios.get
like this
const response = axios.get<ResponseType>(...)
const data = response.data
But jsonp response doesn't have data
field and we should use it like this
const data = axios.jsonp<null, ResponseType>(...)
Can you bring it to universal API?
If we use axios-jsonp-pro with typescript, we dont have the jsonp method in axios object. There are no declaration.
Got this error when using jsop :
Refused to execute script from 'https://sites.google.com/macros/exec?service=AKfycbx_-gZbLP7Z2gGxehXhWMWDAAQsTp3e3bmpTBiaLuzSDQSbIFWD&menu=nama_produk&query=abc&callback=__jp0&_=1513598105820' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
this is snippet my code :
axios
.jsonp(path)
.then((response) => {
console.log('Success when getting data via API ', response)
})
.catch((error) => {
console.log('Error when trying to get via API ', error)
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.