我一直在尝试使用axios向国家公园服务API发出GET请求,并尝试了几种方法在请求标头中设置我的API密钥无济于事.任何帮助将不胜感激.
我试过了:
axios.defaults.headers.common['Authorization'] = "MY-API-KEY";
axios.get('https://developer.nps.gov/api/v0/parks?parkCode=yell')
.then((resp) => {
console.dir(resp);
});
Run Code Online (Sandbox Code Playgroud)
和
let config = {'Authorization': 'MY-API-KEY'};
axios.get('https://developer.nps.gov/api/v0/parks?parkCode=yell', config)
.then((resp) => {
console.dir(resp);
});
Run Code Online (Sandbox Code Playgroud)
当我在Postman中发送GET请求时,它会返回401.它在密钥字段中输入Authorization,在值字段中输入我的API密钥.
谢谢.
我在禁用Leaflet Minimap中的滚轮缩放时遇到问题。我根据https://github.com/Norkart/Leaflet-MiniMap/pull/95使用centerFixed和zoomLevelFixed选项实例化小地图,但是我仍然可以使用滚轮进行缩放;虽然平移是禁用的。
以下是代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="fullscreen.css" />
<!-- Leaflet -->
<link rel="stylesheet"
href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"
type="text/javascript"></script>
<!-- Leaflet Plugins -->
<link rel="stylesheet" href="Control.MiniMap.css" />
<script src="Control.MiniMap.js" type="text/javascript"></script>
</head>
<body>
<div id="map" ></div>
<script type="text/javascript">
var map = new L.Map('map', { scrollWheelZoom: false});
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
var osmAttrib='Map data © OpenStreetMap contributors';
var osm = new L.TileLayer(osmUrl, {/*minZoom: 5, maxZoom: 18,*/ attribution: osmAttrib});
map.addLayer(osm);
map.setView(new L.LatLng(59.92448055859924, 10.758276373601069),10);
//Plugin magic goes here! Note …Run Code Online (Sandbox Code Playgroud)