| Level Navigation: Current Level: 1 | 2 | 3 | 4 | 5 | 6 |
Tags: #lesson #level1 #postman #javascript
Goal: Set up your project and create your first weather function with basic console logging.
In this lesson, you will use your repo from lesson 3.
Postman Code Generation is a powerful feature that automatically converts your API requests into working code snippets. When you click the “Code” button in Postman, it generates ready-to-use JavaScript, Python, or other language code that you can copy and paste directly into your projects.
Instead of having loose API code scattered throughout our script, we’ll create clean, named functions like fetchNewOrleansWeather() that contain all the Postman-generated fetch logic. You’ll first create the function, then immediately call the function to test it.
In this lesson, we will only be logging data to the console. We will update the actual webpage in the next lesson.
fetchNewOrleansWeather function with console.log()script.js, create a function called fetchNewOrleansWeatherconsole.log("Weather for New Orleans") inside the function function fetchNewOrleansWeather() {
console.log("Weather for New Orleans");
}
fetchNewOrleansWeather() and press Enter function fetchNewOrleansWeather() {
console.log("Fetch weather for New Orleans");
}
fetchNewOrleansWeather();
💡 Need help with functions? Check out our JavaScript Reference for function basics.
fetchNewOrleansWeather() is created in script.jsconsole.log("Weather for New Orleans")Ready for the next level? Continue to Level 2: Add Button Challenge
| Level Navigation: Current Level: 1 | 2 | 3 | 4 | 5 | 6 |