jdbence / firestore-parser Goto Github PK
View Code? Open in Web Editor NEWParse the Firestore REST API JSON into a useable JS object
Parse the Firestore REST API JSON into a useable JS object
I am trying to run this on nuxt and axios, and are getting the error that "response.json" is not a function. Please see my code below
getRecords2(vuexContext, context) { let projectId = context.Firestore.projectId || process.env.projectId let url = process.env.fireStoreURL + 'projects/' + projectId + '/databases/(default)/documents/' + context.Firestore.path const token = vuexContext.rootState.auth.token const config = { headers: { Authorization:
Bearer ${token} } } this.$axios .$get(url, config) .then(response => response.json()) .then(json => FireStoreParser(json)) .then(json => console.log(json)) }
Hi! New bug report is here. When you have "field_name": {}
in your database, it translates to mapValue: {}
in REST response, so does not have fields
field, which is expected in your code when parsing mapValue
.
As a result we have "unidentified" passed into getFireStoreProp
function and crash.
@jdbence, would you mind sharing the types you used to parse the data?
arrayValue
not always has values
field. So code can crash:
TypeError: Cannot read property 'map' of undefined
See line 12 of index.js
I logged another call but I think it has nothing to do with axios but with the result I am getting back that need to be parsed. My result is different from yours.
{ "name": "projects/midrandchapel/databases/(default)/documents/about/lFFDPtq5T61BufAOBio0", "fields": { "actions": { "arrayValue": { "values": [ { "mapValue": { "fields": { "text": { "stringValue": "Contact Us" }, "to": { "stringValue": "/contact" }, "color": { "stringValue": "primary darken-4" } } } } ] } }, "md": { "integerValue": "6" }, "showimg": { "booleanValue": true }, "cols": { "integerValue": "12" }, "lg": { "integerValue": "3" }, "subtitle": { "stringValue": "Subtitle or text goes here" }, "xl": { "integerValue": "2" }, "to": { "stringValue": "about/imnew" }, "xs": { "integerValue": "12" }, "text": { "stringValue": "text goes here" }, "sm": { "integerValue": "12" }, "srcavatar": { "stringValue": "https://picsum.photos/id/1005/50/50" }, "title": { "stringValue": "I'm New" }, "src": { "stringValue": "https://picsum.photos/id/1005/5760/3840" }, "page": { "stringValue": "about" }, "sortorder": { "integerValue": "0" } }, "createTime": "2020-04-06T16:18:59.477042Z", "updateTime": "2020-04-08T05:55:02.021686Z" }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.