Cannot get GraphQl to return a corrent response from an array of product IDS

Hello, I am trying to get a correct response from a graphQl query of an array of products. My goal is to take this array of products and sort it from news to oldest published date. I have tested it with a simple array of two product gids but in receiving an error response.

Parse error on “gid://shopify/Product/777229615129” (STRING) at [1, 16]

here is my code:

const shopname = 'storename';
const token = 'Storefront API custom app token';

const queryPage = JSON.stringify({
                  query:`query ($ids : ["gid:\/\/shopify\/Product\/777229615129","gid:\/\/shopify\/Product\/7772297068794"]) {
                    nodes(ids:$ids){
                      ... on Product{
                        id
                        title
                      }
                    }
                  }`
                });
                const storefrontSettingsPage = {
                  "async": true,
                  "crossDomain": true,
                  "url": "https://"+shopname+".myshopify.com/api/2022-07/graphql.json",
                  "method": "POST",
                  "headers": {
                    "X-Shopify-Storefront-Access-Token": token,
                    "Content-Type": "application/json"
                  },
                  "data": queryPage,
                };
$.ajax(storefrontSettingsPage).done(function (response) {
                  console.log(response);
                });

I am still learning to use graphQl, what am I doing wrong.

Thank you for your support.