javascript import fix
This commit is contained in:
		
							parent
							
								
									6a9f0e0968
								
							
						
					
					
						commit
						0cfd054680
					
				
					 12 changed files with 31524 additions and 4 deletions
				
			
		
							
								
								
									
										15755
									
								
								.parcel-cache/753ccae01d2bf714.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15755
									
								
								.parcel-cache/753ccae01d2bf714.txt
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										15753
									
								
								.parcel-cache/76251f8310777ea9.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15753
									
								
								.parcel-cache/76251f8310777ea9.txt
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								assets/imgs/backgroung_dead_trooper.jpg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/imgs/backgroung_dead_trooper.jpg
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 112 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/imgs/backgroung_grogu.jpg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/imgs/backgroung_grogu.jpg
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 96 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/imgs/backgroung_mando.jpg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/imgs/backgroung_mando.jpg
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 103 KiB  | 
| 
						 | 
				
			
			@ -5,7 +5,6 @@
 | 
			
		|||
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
			
		||||
    <link rel="stylesheet" href="styles/style.css">
 | 
			
		||||
    <script src="scripts/util.js"></script>
 | 
			
		||||
    <title>Accueil</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -482,7 +482,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": "echo \"Error: no test specified\" && exit 1",
 | 
			
		||||
    "start": "parcel index.html"
 | 
			
		||||
    "start": "parcel planets.html"
 | 
			
		||||
  },
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@
 | 
			
		|||
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
			
		||||
    <link rel="stylesheet" href="styles/style.css">
 | 
			
		||||
    <script src="scripts/planets.js" type="module" defer></script>
 | 
			
		||||
    <title>Planets</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
| 
						 | 
				
			
			@ -18,6 +19,10 @@
 | 
			
		|||
            </ul>
 | 
			
		||||
        </nav>
 | 
			
		||||
    </section>
 | 
			
		||||
 | 
			
		||||
    <section class="results">
 | 
			
		||||
 | 
			
		||||
    </section>
 | 
			
		||||
    
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										7
									
								
								scripts/planets.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								scripts/planets.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
import { api_call } from "./util";
 | 
			
		||||
 | 
			
		||||
console.log('planet.js loaded');
 | 
			
		||||
 | 
			
		||||
api_call("planets", console.log);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ const URL = "https://swapi.dev/api";
 | 
			
		|||
 * @param {string} endpoint l'endpoint à interroger (ex: planets)
 | 
			
		||||
 * @param {function} callback La fonction qui traitera la réponse JSON en retour
 | 
			
		||||
 */
 | 
			
		||||
const api_call = (endpoint, callback) => {
 | 
			
		||||
export const api_call = (endpoint, callback) => {
 | 
			
		||||
    fetch(`${URL}/${endpoint}`)
 | 
			
		||||
        .then(response => {
 | 
			
		||||
            return response.json();
 | 
			
		||||
| 
						 | 
				
			
			@ -15,4 +15,5 @@ const api_call = (endpoint, callback) => {
 | 
			
		|||
        .then(jsonResp => {
 | 
			
		||||
            callback(jsonResp);
 | 
			
		||||
        });
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue