• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
12

Network request failed error in api calling

Community Beginner ,
Jan 23, 2024 Jan 23, 2024

Copy link to clipboard

Copied

I am using below code for calling some external api in our plugin and getting error: Network request failed

Anyone kindly help to sort out this isue.

 

*********mainfeest.json***********

{
"id": "xyz",
"name": "xyz",
"version": "1.0.1",
"main": "index.html",
"manifestVersion": 5,
"icons": [
{
"width": 48,
"height": 48,
"path": "icons/plugin.png",
"scale": [1, 2],
"theme": ["darkest", "dark", "medium", "lightest", "light", "all"],
"species": ["pluginList"]
}
],

"requiredPermissions": {
"network": {
"domains": ["http://xyz.com"]
},
"clipboard": "readAndWrite",
"webview": {
"allow": "yes",
"domains": ["http://xyz.com"]
},
"launchProcess": {
"schemes": ["https", "slack"],
"extensions": [".xd", ".psd"]
}
}
}
 
**********common function*************:
async function fetchData(API) {
console.log("calling")
try {
const response = await fetch(API);
const data = await response.json();
console.log(data);
} catch (error) {
console.log('Error fetching data:', error);
}
}
************Calling function*************
fetchData("https://xyz.com/abc")
 
API working when I put hostenty else getting error Network request failed
TOPICS
Bug , Experiment , How to , InCopy workflow , Scripting , SDK , UXP Scripting

Views

107

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2024 Mar 10, 2024

Copy link to clipboard

Copied

LATEST

Not really sure how to help on this one

Maybe check the URL is ok - sometimes small typos can cause issues - I was writing a script the other day for illustrator to target a note called 'Folder' and I accendiatlly typed the note in Illustrator as Folder with a paragraph return - I had to write a catch alert in the script to identify why it wasn't working - and it returned the error.


I'm guessing the protocol matches the domain in manifest.json.
Can you check for CORS errors and server permissions?
Maybe security policies?

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines