How to query metabase API using Vue js?
Currently I am able to query metabase using insomnia but when i try to query using vue js i am getting CORS error
I am using Metabase v0.33.2
I am new to metabase please assist
How to query metabase API using Vue js?
Currently I am able to query metabase using insomnia but when i try to query using vue js i am getting CORS error
I am using Metabase v0.33.2
I am new to metabase please assist
Hi @mika
I don’t use Vue, but I would think it would help if you provide your current code.
The Metabase API works with anything that supports RESTful - just for reference:
https://github.com/metabase/metabase/wiki/Using-the-REST-API
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md
Which CORS error are you seeing? https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors
Have you defined Admin > Settings > General > Site URL as the same as how you’re accessing Metabase?
Latest release is 0.33.4 - it has fixed a lot of smaller issues since 0.33.2
Thanks @flamber for your quick reply
here is the code
import axios from 'axios';
const resource = "http://localhost:3000";
const token = "";
const auth = {
headers: { 'X-Metabase-Session': token, 'Content-Type': 'application/json' },
useCredentails: true
}
export class metabase {
static async getToken() {
token = axios.post(resource+"/api/session", { "username": "michaelphandera@gmail.com", "password": "****" }).then(result => {
return result
})
console.log(axios)
return token;
}
static async getDraData(token, filters) {
var queryString = "select * from Data"
if (filters != "") {
queryString += " " + filters;
}
let response = axios.post(resource + "/api/dataset/", { "database": 65, "native": { "query": queryString }, "type": "native" }, auth).then(result => {
return result
})
//console.log(axios)
return response;
}
}
i am looking into your suggestions while i am waiting for your answer for the code above
Please share me api document for v0.33.4 as i cant find it on google may they are different from the older version i was using
@flamber thanks but i am still experiencing the same problem. Please if anyone to help i have already posted the code above
@mika But what errors are you getting? If you can make the API command with CURL or similar, then you know it works, and then you just need to focus on a problem with your Vue project (which means you’ll likely find better help in forum dedicated to Vue).