Custom page with API External

ycastillo
New Member
2 0 0

Good Morning,

It is required that from a custom page access an API External to Shopify. What would be the best way to implement this requirement? what do they advise?

Through javascript using jquery I was able to make the query:

 

$("#btn").on("click", function () {  
  $.ajax({  
                      type: "POST",  
                      url: "https://xxxxxx.com/api",  
                      data: JSON.stringify({  
                          "name": $("#value").val(),  
                      }),
                      dataType: 'json',                    
                      success: function (response) {     
                          console.log(response);
                      },  
            })     
            });  
 
If we see code in the front we can access the URL of the external API (username and password).

What do you recommend using for these types of requirements?
 
best regards
0 Likes
PlankCreative
Explorer
38 9 15

Gday mate!

Unfortunately you cannot make HTTP requests from the Shopify backend, therefore executing API calls with confidential data (password, api key etc) shouldn't be done through the frontend. So the above code, although it works, is highly insecure.

A solution could be to have a separate survey to make the API calls for your store. Server hosting is really cheap on AWS or Google Cloud so it can be quite inexpensive, but is still extra work to setup.

Sorry for the disappointment, but I hope it helps!

Willu

If comment was helpful, hit Like!
Solved your issue? Set Accept as Solution!
Need a quote? Contact glenn@plankcreative.com.au to get in touch!
0 Likes