小编jca*_*pia的帖子

在axios中设置授权标头

我一直在尝试使用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密钥.

谢谢.

get http http-status-code-401 reactjs axios

5
推荐指数
1
解决办法
2万
查看次数

单张小地图滚轮缩放禁用

我在禁用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 &copy; 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)

html javascript leaflet

1
推荐指数
1
解决办法
1871
查看次数

标签 统计

axios ×1

get ×1

html ×1

http ×1

http-status-code-401 ×1

javascript ×1

leaflet ×1

reactjs ×1