Get 2024 Templates Mega Bundle!$1000 worth of 19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets for just $9
Get for 99$

How to work with Directus API


I tried to create a new record for "Test_Collection" collection in directus with this function in ApiService.ts file

public static test() {
ApiService.vueInstance.axios
.post("/items/Test_Collection", { name: "test", result: "123" }, {
headers: { "Content-type": "application/json;" },
})
.catch((error) => {
throw new Error(`[KT] ApiService ${error}`);
});
}


the API still reached my directus backend but the payload became an empty Object {}, it only happen when the API is called through ApiService.ts file. If i call the API like this from anywhere else it work normally

handleTestInsert3() {
ApiService.vueInstance.axios.post("/items/Test_Collection", { name: "test", result: "123" }, { headers: { "Content-Type": "application/json" } }
).catch((error) => {
throw new Error(`[KT] ApiService ${error}`);
});
}


i wonder if there anyway to make it work as intended


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi,

Sorry for the late reply.

Currently, we haven't tried integrating Metronic with the Directus API, but we will explore this possibility if there is sufficient demand.

Please ensure that your backend correctly retrieves the request data. To verify that your API is functioning properly, you can test the request using Postman.

Additionally, let us know if you encounter any client errors when making this request.

Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(