How to envoke a client side API in codeless for the CodelessShoppingCartService Serverless 2of3 mission

Mission: SERVERLESS 101
Task: Invoke the API Service using generated client SDK

Within a Codeless environment which block should be used to invoke the API calls and how would I obtain the usertoken please?

It’s the last task I need to complete ! :slight_smile: to unlock Springboard !

Hi, @Graham_Reddie

In order to pass this mission you need go to the Business Logic section. Add there Codeless sample “shopping cart” service. And just follow thw instructions from the mission description. Also you can open “shopping cart” service go to the Codeless tab and you will find there all the blocks and logic which were used for it.
https://monosnap.com/direct/exjgbejzzitKyOZkxaFrWHS5x2qeqA

Regards,
Marina

Hi Marina,

I’ve already done that and I’ve completed…

  1. Deploy Sample API Service and
  2. Generate API docs for the API Service

but I’m struggling with

  1. Invoke the API Service using generated client SDK

…since I’m trying to achieve it within codeless rather than JS.

Can you help with how to complete this task in codeless?

As a newbie and someone that prefers to use codeless I’m keen to stay on that track rather than switch to JS just to achieve the objective.

This task will be marked as complete when you invoke the following methods on the CodelessShoppingCartService in Business Service tap:

  1. Invoke the getInstructions() API service method.
  2. Invoke the addItem() API service method. With cartName “string”
  3. Invoke the tems() API service method. With the same body as you see in Schema of body (you can just click on it and it will be copied to body).
  4. Invoke the purchase() API service method.With cartName “string”

Done, just follow these steps.

Regards,
Marina

Okay I see now… it’s always easy when you know how!

Given i’ve just finished the mission and it asks for feedback, my advice would be that for newbies that intend to use codeless, you should provide a codeless example and not just JS. Whilst I’ve learnt a lesson in how to use JS I would have preferred to have stuck with Codeless since this is the “language” I’m attempting to use in conjunction with Backendless. The other thing I would say is don’t mix the examples with syntax, I was confused by the reference to “string”, I thought you were referring to a data type, if might have been better if the string were “basket1” or something like that.

I’ve really enjoyed the missions and the system is excellent, so great job on all fronts

Thanks for your support too.

Graham.

5 Likes

Thanks for your attention and suggestion. I will offer it to our team.

Happy Coding with Backendless!

Regards,
Marina

Hi,
…I have the same problem than Graham, so I followed all the steps you mentioned and I succeeded in the mission, but just to comment that in the instructions is said:

3.- invoke getItems instead of the method Items.
I also think is not good idea to use “string” as identification because it confusing for us.

As I hadn’t see this post, I tried to do with SKD JS. Quite difficult for me as I do not have any knowledge at all of any programming languages neither html…so a real nocode seeker.

I would like to follow the mission with JS to understand how is the procedure when we use no codeless in client side.

At this moment and before invoke any method, there are some errors in the console just when I open index.html:

–> backendless.min.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
–> Uncaught ReferenceError: Backendless is not defined
at CodelessShoppingCartService.js:15
(anonymous) @ CodelessShoppingCartService.js:15
–> Uncaught SyntaxError: missing ) after argument list

This last…I have reviewed deeply all the wording which is the following but I’m not able to find the typing error:

function addItem(){
this.CodelessShoppingCartService.Item( cartName: ‘mycart’, item: {‘name’: ‘Milk’, ‘quantity’:3 })
.then(function(){
log(‘Item added’);
})
}

Thank you
David

Hello @David_Najar_Martinez

I am founded several mistakes in this part of the code and think you lose something in the code that you don’t show.

Can you provide the full code?

function addItem(){
    this.CodelessShoppingCartService.Item( 'mycart', {'name': 'Milk', 'quantity':3 })
    .then(function(){
        log('Item added');
    })
}

Regards, Dima.