Back to changelog
Changelog

Cosmic JavaScript SDK updates (v1.2.0)

Cosmic's avatar

Cosmic

October 01, 2024

cover image

We recently released a new version of the Cosmic JavaScript SDK (v1.2.0) which includes features and improvements to enhance your developer experience and streamline content delivery.

Props graph syntax

In v1.2.0 you can now use graph style syntax to declare your API response properties. The shape you request is the shape you get.

props-graph-syntax.jpg

For example, when you make a request like this:


You get this response back:


This is a much improved way to structure your requests to the API especially when you have more deeply nested props. Note: The props string and array options are still supported.

Go to the Objects section in the docs for more information.

Fetch additional media data

The new method enables you to get more media data from your media Metafields. It's available on the Objects and  methods. This method takes an object with and . Here's what it looks like:


This will now add the , , and to all media Metafields (if available). For example:


This feature makes adding accessibility and handling image dimensions simpler. Go to the media section in the docs to see all available properties on the media model.

Media dimensions

Images uploaded to the Cosmic dashboard and API now include  and  values for easy access.

dimensions.png

Go to the docs to review the latest updates.