Wipeout!


👋,

We were excited to be invited to Webflow's livestream, Add AI to your Webflow builds with these Webflow apps. It did not go as planned. 🤦‍♂️

Aron's project was deleted prior to the demo but also open in another tab. Although it appeared to still be functioning properly, the project files were inaccessible. You can see the breakdown here.

(Get a free month subscription using the code "wipeout".)


👀 We are working on several tasks based on feedback from users like you.

  • The minification of your code in production will be a setting that you can toggle on and off.
  • Better support for Single Script pages
  • Faster production script creation in regions outside of the US
  • Support for Webflow localization

How can we make Slater better for you? Reply to this email or join our Slack.


Javascript 101: Fetching Data with an API

This week, we've been working with several APIs. Using an API is magical! To give you a taste of this magic, we're going to use Javascript's fetch to perform a GET and POST request to an external API.

Let's use the JSONPlaceholder API, which is a free fake API for testing and prototyping.

Fetching Data from an Open API

// Fetch all posts
fetch('https://jsonplaceholder.typicode.com/posts')
  .then(response => response.json())
  .then(posts => {
    // Process the posts data
    console.log(posts);
  })
  .catch(error => console.error(error));


// Fetch a specific post
fetch('https://jsonplaceholder.typicode.com/posts/1')
  .then(response => response.json())
  .then(post => {
    // Process the post data
    console.log(post);
  })
  .catch(error => console.error(error));

Sending Data to an Open API

const newPost = {
  title: 'New Post',
  body: 'This is a new post created from the Fetch API',
  userId: 1
};

fetch('https://jsonplaceholder.typicode.com/posts', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(newPost)
})
  .then(response => response.json())
  .then(post => {
    // Process the new post data
    console.log(post);
  })
  .catch(error => console.error(error));

Here's a breakdown of what's happening:

  1. fetch('https://jsonplaceholder.typicode.com/posts') fetches all posts from the API.
  2. fetch('https://jsonplaceholder.typicode.com/posts/1') fetches a specific post with the ID of 1.
  3. We create a new post object newPost with a title, body, and user ID.
  4. fetch('https://jsonplaceholder.typicode.com/posts', { ... }) sends a POST request to the API with the newPost object in the request body.

Note that JSONPlaceholder is a fake API, so while you can send POST requests, it won't actually create new resources on the server. However, it's a great resource for testing and learning purposes.

Open up the console in your browser and paste in the code to see it work. Like magic, you will get and post data to JSONPlaceholder. Getting data from a commercial API may take a little more work but it isn't that much different from what we do in this Javascript 101.

Let us know what APIs you want to use! Happy coding!

🤙 The Slater team


If Slater helps you create better websites, please support the team behind it.



1295 Canyon View Rd, Midway, UT 84049
Unsubscribe · Preferences

Welcome To Slater!

Slater resources, updates and community activity

Read more from Welcome To Slater!
video preview

How has your Webflow Conf 2024 experience been? At Edgar Allan, we are especially excited about Webflow Analyze and Optimize and how we can leverage it for our clients and with Wes. However, at Slater, we are most excited about the GSAP acquisition. We’ve been thinking about how we can better support you as you integrate GSAP and Webflow. Let’s explore how you can use Slater with GSAP: Slater Sessions - GSAP + Webflow via Chat with Witt Learn GSAP for Webflow with Aron Korenblit and Cassie...

photo

Do you get confused when undoing (cmd + z) in Slater? We auto-format your code on save. The auto-formatting updates your code, and those updates get pushed into the undo stack. You can now improve your workflow by formatting the code when you choose—not just on save. To gain more control over when your code formats: Turn off auto-format code in the Code Editor Settings Use cmd + shift + f to format your code We added a handful of other improvements: Console logs and debuggers are now...

video preview

Last week, we announced that CSS updates were on the way—and now they're here! You can now generate CSS files just as quickly and easily as JS files. In the video below, we give a quick demo of the new functionality. If you have a Smart Script loaded in your project, you can instantly add CSS. In the demo, we also show how to add CSS in the Webflow designer. Give it a try and let us know what you're building! Community Library 🖍️ Text Highlight ColorCSS code for custom text selection. 🅰...