ymaps.geocode 403 Не передается параметр apikey при динамическом вызове скрипта

ymap.geocode 403

full-1482a76126513edc06c1006be2047397367fffa0.js:167132 GET https://api-maps.yandex.ru/services/search//v2/?callback=id_160355055543717903649&text=%D0%A0%D0%BE%D1%81%D1%81%D0%B8%D1%8F%2C%20%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0%2C%20%D1%83%D0%BB%D0%B8%D1%86%D0%B0%20%D0%92%D0%B0%D0%B2%D0%B8%D0%BB%D0%BE%D0%B2%D0%B0%20&format=json&rspn=0&lang=ru_RU&results=1&token=f3dacb3ffeefee0b3b50198069db7da0&type=geo&properties=addressdetails&geocoder_sco=latlong&origin=jsapi2Geocoder net::ERR_ABORTED 403 (Forbidden)

Если в эту строку дополнить параметром apikey со значением, скрипт отработает успешно. Но параметр apikey не передается.

        class Address{
        constructor(options){
            let self = this;
            options = options||{};

            if( !options.key) return false;
            this.id = 'address' + (state.address.id++);
            this.state = new State(this.id); 

            this.setBeforeAddress(options.country, options.city);
            // &load=SuggestView,geocode,suggest
            loadScript('//api-maps.yandex.ru/2.1/?apikey'+options.key+'=&lang=ru_RU&mode=debug&hasApiKeyParam=1', ()=>{ ymaps.ready(self.init.bind(self)) });
          
        }
        init() {
            let self = this;


            var suggestView = new ymaps.SuggestView('suggest',  {
                results: 10,
                provider: {
                    suggest: function (request, options) {
                        let before = self.state.get('before');
                        return ymaps.suggest(before + request, {results: 10});
                    }
                }
            });

            suggestView.events.add('select', function (event) {
                let value = event.get('item').value;
                if( value ) {
                    ymaps.geocode(value, {results: 1}).then(
                    function (res) {
                        var obj = res.geoObjects.get(0);
                        res.geoObjects.get(0).properties.getAll()
                        console.log(obj, res.geoObjects.get(0).properties.getAll())
                        
                    },
                    function (err) {
                        console.log(err)
                    });
                }
            });
        }

        setBeforeAddress( country, city ) {
            let before = '';
            if (country) before += country + ', ';
            if (city) before += city + ', ';
            this.state.set('before', before);
            return this;
        }
    }

https://yastatic.net/s3/front-maps-static/front-jsapi-v2-1/2.1.77-27/build/debug/full-1482a76126513edc06c1006be2047397367fffa0.js

После загрузки этого скрипта в провайдере geocode значение ym.env.apikey не определено

Как передать значение ключа?


незначительный момент var serviceUrl = ym.env.hosts.api.services.search + '/v2/'; serviceUrl


Ответы (0 шт):