Alireza Mortezaei
Alireza Mortezaei

Reputation: 19

axios doesn't work on Samsung Tizen TVs but works fine in emulator

simple axios works fine in emulator and browsers but doesn't work on Samsung Tizen TV 2016 and there is no error in console.

with using cdn:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

and script like this:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Tizen basic template generated by Tizen Web IDE"/>

    <title>Tizen Web IDE - Tizen - Samsung Tizen TV basic Application</title>

    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script src="js/main.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>

<body style="width: 1920px; height:1080px; position: fixed;">

  <script>  
      axios.get('https://api.github.com/users/axios')
      .then(function(response){
      console.log(response.data);
      id = response.data.id;
      alert(id);
      });
  </script>
</body>
</html>

Upvotes: 0

Views: 964

Answers (2)

basti500
basti500

Reputation: 886

You need to set the privilege and the access policy in the config.xml

Privilege

In order give the permission to access the network you need to set it in the tizen studio.

Set Internet Privilege in tizen studio

<tizen:privilege name="http://developer.samsung.com/privilege/network.public"/>

Policy

Hery you need set set which urls you can access. enter image description here

<access origin="*" subdomains="true"/>

Upvotes: 1

Alireza Mortezaei
Alireza Mortezaei

Reputation: 19

solved. there's a line of code that must be added to our script before using axios:

axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';

Upvotes: 1

Related Questions