Some actions JS blocks cannot be parsed as JS code

Hi,

I am trying to publish my plugin but this piece of code is causing Bubble to throw the error “Action plugin: Some actions JS blocks cannot be parsed as JS code. Please check.”.

The piece of code works perfectly fine in my test app, but Bubble just won’t let me publish it. There are no errors in the console or in the code editor for action. It’s running as a server-side action.

If anyone has a minute can you please review the code and suggest any reasons why Bubble may not be able to publish it? :crossed_fingers:

Thank you all!!!

function(properties, context) {
    
 
const response = context.request({
    
method: "post",
    
uri: "https://paper.xyz/api/v1/checkout",
    
headers: {"Accept": "application/json",
                 "Authorization": "Bearer <MYAPIKEY>",
                 "Content-Type": "application/json"},
    
 body:{ "contractChain": properties.contract_chain,
       "contractType": "THIRDWEB_NFT_DROP_V2",  
       "requireVerifiedEmail": false,
       "hideNativeMint": false,
       "hidePayWithCard": false,
       "hidePayWithCrypto": false,
       "hideConnectPaperWallet": false,
       "hideConnectExternalWallet": false,
       "brandDarkMode": false,
       "brandButtoneShape": "lg",
       "brandColorScheme": properties.color_scheme,
       "hasPublicLink": true,
       "limitPerTransaction": properties.limit_per_transaction,
       "redirectAfterPayment": false,
       "shouldSendTransferCompletedEmail": true,
       "successCallbackUrl": properties.success_url,
       "contractAddress": properties.contract_address,
       "collectionDescription": properties.collection_description,
       "collectionTitle": properties.collection_name,
       "cancelCallbackUrl": properties.cancel_url,
       "imageUrl": properties.image_url,
       "sellerTwitterHandle": properties.seller_twitter_handle},
    
json: true});   
    
   
return {checkouturl: JSON.stringify(response.body.checkoutUrl).replace('"','').replace('"','')};   

}

Assuming you’re creating a server side action?

I think I had a similar issue when I accidentally left some bad code in the client side code section.

Alternatively, run your code through a javascript parser or use VS Code

What I do when this happens is;

  • copy the method code into a text editor eg Sublime to get rid of any wonky chars
  • delete the action and create from scratch a new plug-in method (paste in the code from step 1) to get rid of any orphan references from the screwed up plug-in method.

Good luck :slightly_smiling_face:

2 Likes

That was the problem! Thank you!

Thank you for your response!