No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Best way to call backend api

    Help
    4
    5
    550
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      arkaprova last edited by

      Could you please let me know what is the best way to call backend api from quasar ? Is there any design pattern we can follow ? How can reuse the return object in multiple pages once api is called ?

      I 1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        What is your backend supporting? Rest? GraphQL?

        Scott

        A 1 Reply Last reply Reply Quote 0
        • I
          Ilia @arkaprova last edited by

          @arkaprova You can use axios for POSTing and GETting backend API and wrap the response into JSON file containing

          {
            status: true/false,
            data: {
              key1: value1,
              key2: value2,
              etc.
            }
          }
          

          Status can be specified as codes instead, like status: 200 | status: 400 | etc.
          Data can be string | array | object | number

          That all would really depend on how you read the requests and return the values in backend.

          1 Reply Last reply Reply Quote 0
          • A
            arkaprova @s.molinari last edited by

            @s-molinari Rest api

            1 Reply Last reply Reply Quote 0
            • beets
              beets last edited by

              I personally like using the fetch api, but axios works too. As far as how I structure it, I usually have a boot file that injects an instance of a class into Vue.prototype.$api so I can call it anywhere like this.$api.getUsers()

              1 Reply Last reply Reply Quote 1
              • First post
                Last post