Вот код api.js Vue CLI, что в нем не так?
import rp from 'request-promise';
const requestOptions = {
method: 'GET',
uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
qs: {
start : 1,
limit: 5,
convert: 'USD'
},
headers: {
'X-CMC_PRO_API_KEY': 'b54bcf4d-1bca-4e8e-9a24-22ff2c3d462c',
'Access-Control-Allow-Origin': '*'
},
json: true
};
rp(requestOptions).then(response => {
const result = response.data;
}).catch((err) => {
err.message;
});
При попытке получить доступ к coinmarketcap API, выдает вот такие ошибки:
1. OPTIONS
https://pro-аpi.coinmarketcap.com/v1/cryptocurrenc... 500
2. Access to fetch at '
https://pro-api.coinmarketcap.com/v1/cryptocurrenc...' from origin '
localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.