Im using REST adapter by ember-data and it works fine. But now I want to use local storage for user settings storing.
Please, explain me, what is the right way?
I'm using ember-cli.
All you need to do is create a file in the adapters folder, with the same name of your model
//app/adapters/settings.js
import LSAdapter from "your_adapter"
export default LSAdapter.extend();
For local storage you can use Local Forage Adapter
Related
I'm having this problem for quite a while and want to solve this:
According to supbase documentation you create a .env file
VITE_SUPABASE_URL="YOUR_SUPABASE_URL"
VITE_SUPABASE_ANON_KEY="YOUR_SUPABASE_KEY"
then you call them in supabaseClient.js:
import { createClient } from '#supabase/supabase-js'
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
However this doesnt work,I get supabaseUrl is required. and the env variables are not getting exported.
Does anyone know why and how to solve it?
Do I need to install any additional lib?
Thank you in advance
SvelteKit recently added new stores to import env variables, like $env/static/private. To use:
# .env file
PUBLIC_SUPABASE_URL="YOUR_SUPABASE_URL"
PUBLIC_SUPABASE_ANON_KEY="YOUR_SUPABASE_KEY"
// supabaseClient.js
import { createClient } from '#supabase/supabase-js'
import {PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY} from '$env/static/public'
export const supabase = createClient(PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY)
This should work, however note your secrets are being exposed in publicly accessible JS files (thus the PUBLIC_ prefix). So it is better to only access supabase from SvelteKit endpoints (which that tutorial doesn't do.) To do this, you should use the $env/static/private store and env variables without the PUBLIC_ prefix. (You will also have to refactor your supabase code to be in a Svelte endpoint, not a Svelte page/component.)
Warning: The SvelteKit API is in flux, and the final v1.0 way to do this may be quite different. The latest SvelteKit already introduced major breaking changes:
https://github.com/sveltejs/kit/discussions/5748
https://github.com/sveltejs/kit/discussions/5875
I have used the old VITE_SUPABASE_URL + import.meta.env.VITE_SUPABASE_URL method before, so it should work. I'm not sure if SvelteKit disabled this method as they introduced the new env variable stores.
update: If you would like to continue using the old import.meta.env.VITE_SUPABASE_URL method, it may be possible by setting envPrefix in your vite.config.js (Source: https://kit.svelte.dev/docs/configuration#env)
I want to use the cloudwatchlog client from AWS SDK (JS) and also set the credentials. So that I am not including the whole AWS SDK bundle inside my Application, because it is very large and slows down the page. Is there a way to configure the credentials and then only use the needed client from the AWS SDK?
so far I have tried this but it doesn't work with the config, typescript says the update method doesn't exist on Config:
import {Config} from 'aws-sdk/lib/core';
import {CloudWatchLogs} from 'aws-sdk';
Luckily I have just done this the other day to shrink down my bundle size as well.
First I would recommend getting the correct aws-sdk config library with:
let Config = require('aws-sdk/global');
To get just the individual CloudWatchLogs you would need to get it like so:
let CloudWatchLogs = require('aws-sdk/clients/cloudwatchlogs');
After this you can configure the credentials like you would before, and to get a new CloudWatchLog you can do: let cloudwatch = new CloudWatchLogs()
Hopefully this helps some.
How to store a file on React Native, that once the system store that particular file, you won't need to rely on localhost to provide the access to the file itself.
I have a react native directory with files as shown:
...
|-android
|-ios
|-node_modules
...
|-App.js
|-tensorflow_inception_graph.pb
|-labels.txt
|-result.js
|
...
I'm importing the "tensorflow_inception_graph.pb" using the following line of code:
import model from 'MyTensorFlow/tensorflow_inception_graph.pb';
import model from 'MyTensorFlow/tensorflow_inception_graph.pb';
Likewise, I have also tried using the following line of code:
import model from './tensorflow_inception_graph.pb';
import model from './tensorflow_inception_graph.pb';
Result that I hoping to get:
I could run the application and access the files stated above without ever getting the error message like Debugging on physical phone. This indirectly also means that I could run the application without attach the cable to my physical phone.
I wonder am I doing wrongly in the first place, I find the documentation provided by the 'react-native-tensorflow' is inadequate for a beginner to react native like me.
I hope someone can shed some light on this for me. Thank you.
I've watched this example that uses Node.js (Express.js):
https://github.com/danialfarid/ng-file-upload/wiki/Node-example
My question is: How to create a service in Sails.js that can be used in Angular.js (View), that allows store files in a folder of the project, using connect-multiparty like the example?
Create a controller method in Sails
Bind it to a route in routes.js
Use connect-multiparty at top of your controller method (OR use it as a middleware in config/http.js)
I have folder, with a lot of JSON files:
-json
--file1.json
--anotherfile.json
...
--lastfile.json
How can I import all of them from that folder, without explicitly defining their names?
Suppose, I should use something like this:
import * as jsonFiles from './json'
but it doesn't work.
So, how can I do this?
Important note: this is not Node.js, I'm using it with React on client side.
The list of files from server side cannot be retrieved from client side, especially if the app isn't prebuilt with build tool but uses ES6 module loader.
The proper way here is to retrieve jsonFiles object via AJAX request on client side, and the server is responsible for reading the directory and merging JSON files into a single object.