Error downloading openstreetmap tile on react-native

203 Views Asked by At

I'm making a react-native application and I need to allow to use the map without internet. For this I download the tiles on the mobile with react-native-fs. I don't understand the following error:

[Error: Unable to resolve host "tile.openstreetmap.org": No address associated with hostname]

On postman I have to put a Host field in the header but in the doc I don't have this field indicated : https://operations.osmfoundation.org/policies/tiles/

postman request

request:

    RNFS.downloadFile({
      fromUrl: link,
      toFile:
        dir +
        '/' +
        splitLink[splitLink.length - 3] +
        '/' +
        splitLink[splitLink.length - 2] +
        '/' +
        splitLink[splitLink.length - 1],
      headers: {
        'User-Agent': 'android',
      },
    })
      .promise.then(response => {
        console.log('response', response);
        if (response.statusCode === 200) {
          return console.log('FILES UPLOADED!', response);
        } else {
          console.log('SERVER ERROR');
        }
      })
      .catch(err => {
        console.log('err', err);
      });

I think it's the Host field that's missing in my request but I can't find what value to put.

Thanks for your help :)

0

There are 0 best solutions below